<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">{-
(c) The AQUA Project, Glasgow University, 1993-1998

\section[GHC.Core.Opt.Simplify.Monad]{The simplifier Monad}
-}</span><span>
</span><span id="line-6"></span><span>
</span><span id="line-7"></span><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-8"></span><span>
</span><span id="line-9"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Core.Opt.Simplify.Env</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-10"></span><span>        </span><span class="annot"><span class="hs-comment">-- * The simplifier mode</span></span><span>
</span><span id="line-11"></span><span>        </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#setMode"><span class="hs-identifier">setMode</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#getMode"><span class="hs-identifier">getMode</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#updMode"><span class="hs-identifier">updMode</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#seDynFlags"><span class="hs-identifier">seDynFlags</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-12"></span><span>
</span><span id="line-13"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Environments</span></span><span>
</span><span id="line-14"></span><span>        </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier">SimplEnv</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#pprSimplEnv"><span class="hs-identifier">pprSimplEnv</span></a></span><span class="hs-special">,</span><span>   </span><span class="hs-comment">-- Temp not abstract</span><span>
</span><span id="line-15"></span><span>        </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#mkSimplEnv"><span class="hs-identifier">mkSimplEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#extendIdSubst"><span class="hs-identifier">extendIdSubst</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-16"></span><span>        </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#extendTvSubst"><span class="hs-identifier">extendTvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#extendCvSubst"><span class="hs-identifier">extendCvSubst</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-17"></span><span>        </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#zapSubstEnv"><span class="hs-identifier">zapSubstEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#setSubstEnv"><span class="hs-identifier">setSubstEnv</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-18"></span><span>        </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#getInScope"><span class="hs-identifier">getInScope</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#setInScopeFromE"><span class="hs-identifier">setInScopeFromE</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#setInScopeFromF"><span class="hs-identifier">setInScopeFromF</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-19"></span><span>        </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#setInScopeSet"><span class="hs-identifier">setInScopeSet</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#modifyInScope"><span class="hs-identifier">modifyInScope</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#addNewInScopeIds"><span class="hs-identifier">addNewInScopeIds</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-20"></span><span>        </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Monad.html#getSimplRules"><span class="hs-identifier">getSimplRules</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-21"></span><span>
</span><span id="line-22"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Substitution results</span></span><span>
</span><span id="line-23"></span><span>        </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplSR"><span class="hs-identifier">SimplSR</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#mkContEx"><span class="hs-identifier">mkContEx</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#substId"><span class="hs-identifier">substId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#lookupRecBndr"><span class="hs-identifier">lookupRecBndr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#refineFromInScope"><span class="hs-identifier">refineFromInScope</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-24"></span><span>
</span><span id="line-25"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Simplifying 'Id' binders</span></span><span>
</span><span id="line-26"></span><span>        </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#simplNonRecBndr"><span class="hs-identifier">simplNonRecBndr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#simplNonRecJoinBndr"><span class="hs-identifier">simplNonRecJoinBndr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#simplRecBndrs"><span class="hs-identifier">simplRecBndrs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#simplRecJoinBndrs"><span class="hs-identifier">simplRecJoinBndrs</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-27"></span><span>        </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#simplBinder"><span class="hs-identifier">simplBinder</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#simplBinders"><span class="hs-identifier">simplBinders</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-28"></span><span>        </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#substTy"><span class="hs-identifier">substTy</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#substTyVar"><span class="hs-identifier">substTyVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#getTCvSubst"><span class="hs-identifier">getTCvSubst</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-29"></span><span>        </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#substCo"><span class="hs-identifier">substCo</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#substCoVar"><span class="hs-identifier">substCoVar</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-30"></span><span>
</span><span id="line-31"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Floats</span></span><span>
</span><span id="line-32"></span><span>        </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier">SimplFloats</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#emptyFloats"><span class="hs-identifier">emptyFloats</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#mkRecFloats"><span class="hs-identifier">mkRecFloats</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-33"></span><span>        </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#mkFloatBind"><span class="hs-identifier">mkFloatBind</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#addLetFloats"><span class="hs-identifier">addLetFloats</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#addJoinFloats"><span class="hs-identifier">addJoinFloats</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#addFloats"><span class="hs-identifier">addFloats</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-34"></span><span>        </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#extendFloats"><span class="hs-identifier">extendFloats</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#wrapFloats"><span class="hs-identifier">wrapFloats</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-35"></span><span>        </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#doFloatFromRhs"><span class="hs-identifier">doFloatFromRhs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#getTopFloatBinds"><span class="hs-identifier">getTopFloatBinds</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-36"></span><span>
</span><span id="line-37"></span><span>        </span><span class="annot"><span class="hs-comment">-- * LetFloats</span></span><span>
</span><span id="line-38"></span><span>        </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#LetFloats"><span class="hs-identifier">LetFloats</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#letFloatBinds"><span class="hs-identifier">letFloatBinds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#emptyLetFloats"><span class="hs-identifier">emptyLetFloats</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#unitLetFloat"><span class="hs-identifier">unitLetFloat</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-39"></span><span>        </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#addLetFlts"><span class="hs-identifier">addLetFlts</span></a></span><span class="hs-special">,</span><span>  </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#mapLetFloats"><span class="hs-identifier">mapLetFloats</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-40"></span><span>
</span><span id="line-41"></span><span>        </span><span class="annot"><span class="hs-comment">-- * JoinFloats</span></span><span>
</span><span id="line-42"></span><span>        </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#JoinFloat"><span class="hs-identifier">JoinFloat</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#JoinFloats"><span class="hs-identifier">JoinFloats</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#emptyJoinFloats"><span class="hs-identifier">emptyJoinFloats</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-43"></span><span>        </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#wrapJoinFloats"><span class="hs-identifier">wrapJoinFloats</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#wrapJoinFloatsX"><span class="hs-identifier">wrapJoinFloatsX</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#unitJoinFloat"><span class="hs-identifier">unitJoinFloat</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#addJoinFlts"><span class="hs-identifier">addJoinFlts</span></a></span><span>
</span><span id="line-44"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-49"></span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Monad.html"><span class="hs-identifier">GHC.Core.Opt.Simplify.Monad</span></a></span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Monad.html"><span class="hs-identifier">GHC.Core.Opt.Monad</span></a></span><span>        </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Monad.html#SimplMode"><span class="hs-identifier">SimplMode</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.html"><span class="hs-identifier">GHC.Core</span></a></span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html"><span class="hs-identifier">GHC.Core.Utils</span></a></span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Multiplicity.html"><span class="hs-identifier">GHC.Core.Multiplicity</span></a></span><span>     </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Multiplicity.html#scaleScaled"><span class="hs-identifier">scaleScaled</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-55"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.html"><span class="hs-identifier">GHC.Types.Var</span></a></span><span>
</span><span id="line-56"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html"><span class="hs-identifier">GHC.Types.Var.Env</span></a></span><span>
</span><span id="line-57"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html"><span class="hs-identifier">GHC.Types.Var.Set</span></a></span><span>
</span><span id="line-58"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.OrdList.html"><span class="hs-identifier">GHC.Data.OrdList</span></a></span><span>
</span><span id="line-59"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.html"><span class="hs-identifier">GHC.Types.Id</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Id</span></span><span>
</span><span id="line-60"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Make.html"><span class="hs-identifier">GHC.Core.Make</span></a></span><span>            </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Make.html#mkWildValBinder"><span class="hs-identifier">mkWildValBinder</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-61"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span>       </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier">DynFlags</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-62"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Types.html"><span class="hs-identifier">GHC.Builtin.Types</span></a></span><span>
</span><span id="line-63"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html"><span class="hs-identifier">GHC.Core.TyCo.Rep</span></a></span><span>        </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyCoBinder"><span class="hs-identifier">TyCoBinder</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-64"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Type</span></span><span>
</span><span id="line-65"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span> </span><span class="hs-keyword">hiding</span><span>     </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier">substTy</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTyVar"><span class="hs-identifier">substTyVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substTyVarBndr"><span class="hs-identifier">substTyVarBndr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendTvSubst"><span class="hs-identifier">extendTvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#extendCvSubst"><span class="hs-identifier">extendCvSubst</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-66"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html"><span class="hs-identifier">GHC.Core.Coercion</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Coercion</span></span><span>
</span><span id="line-67"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html"><span class="hs-identifier">GHC.Core.Coercion</span></a></span><span> </span><span class="hs-keyword">hiding</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substCo"><span class="hs-identifier">substCo</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substCoVar"><span class="hs-identifier">substCoVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#substCoVarBndr"><span class="hs-identifier">substCoVarBndr</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-68"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html"><span class="hs-identifier">GHC.Types.Basic</span></a></span><span>
</span><span id="line-69"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html"><span class="hs-identifier">GHC.Utils.Monad</span></a></span><span>
</span><span id="line-70"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-71"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>
</span><span id="line-72"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.FM.html"><span class="hs-identifier">GHC.Types.Unique.FM</span></a></span><span>      </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Unique.FM.html#pprUniqFM"><span class="hs-identifier">pprUniqFM</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-73"></span><span>
</span><span id="line-74"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Traversable.html#mapAccumL"><span class="hs-identifier">mapAccumL</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-75"></span><span>
</span><span id="line-76"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
\subsubsection{The @SimplEnv@ type}
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-83"></span><span>
</span><span id="line-84"></span><span class="hs-keyword">data</span><span> </span><span id="SimplEnv"><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-var">SimplEnv</span></a></span></span><span>
</span><span id="line-85"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="SimplEnv"><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-var">SimplEnv</span></a></span></span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-86"></span><span>     </span><span class="hs-comment">----------- Static part of the environment -----------</span><span>
</span><span id="line-87"></span><span>     </span><span class="hs-comment">-- Static in the sense of lexically scoped,</span><span>
</span><span id="line-88"></span><span>     </span><span class="hs-comment">-- wrt the original expression</span><span>
</span><span id="line-89"></span><span>
</span><span id="line-90"></span><span>        </span><span id="seMode"><span class="annot"><span class="annottext">SimplEnv -&gt; SimplMode
</span><a href="GHC.Core.Opt.Simplify.Env.html#seMode"><span class="hs-identifier hs-var hs-var">seMode</span></a></span></span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Monad.html#SimplMode"><span class="hs-identifier hs-type">SimplMode</span></a></span><span>
</span><span id="line-91"></span><span>
</span><span id="line-92"></span><span>        </span><span class="hs-comment">-- The current substitution</span><span>
</span><span id="line-93"></span><span>      </span><span class="hs-special">,</span><span> </span><span id="seTvSubst"><span class="annot"><span class="annottext">SimplEnv -&gt; TvSubstEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#seTvSubst"><span class="hs-identifier hs-var hs-var">seTvSubst</span></a></span></span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TvSubstEnv"><span class="hs-identifier hs-type">TvSubstEnv</span></a></span><span>      </span><span class="hs-comment">-- InTyVar |--&gt; OutType</span><span>
</span><span id="line-94"></span><span>      </span><span class="hs-special">,</span><span> </span><span id="seCvSubst"><span class="annot"><span class="annottext">SimplEnv -&gt; CvSubstEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#seCvSubst"><span class="hs-identifier hs-var hs-var">seCvSubst</span></a></span></span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#CvSubstEnv"><span class="hs-identifier hs-type">CvSubstEnv</span></a></span><span>      </span><span class="hs-comment">-- InCoVar |--&gt; OutCoercion</span><span>
</span><span id="line-95"></span><span>      </span><span class="hs-special">,</span><span> </span><span id="seIdSubst"><span class="annot"><span class="annottext">SimplEnv -&gt; SimplIdSubst
</span><a href="GHC.Core.Opt.Simplify.Env.html#seIdSubst"><span class="hs-identifier hs-var hs-var">seIdSubst</span></a></span></span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplIdSubst"><span class="hs-identifier hs-type">SimplIdSubst</span></a></span><span>    </span><span class="hs-comment">-- InId    |--&gt; OutExpr</span><span>
</span><span id="line-96"></span><span>
</span><span id="line-97"></span><span>     </span><span class="hs-comment">----------- Dynamic part of the environment -----------</span><span>
</span><span id="line-98"></span><span>     </span><span class="hs-comment">-- Dynamic in the sense of describing the setup where</span><span>
</span><span id="line-99"></span><span>     </span><span class="hs-comment">-- the expression finally ends up</span><span>
</span><span id="line-100"></span><span>
</span><span id="line-101"></span><span>        </span><span class="hs-comment">-- The current set of in-scope variables</span><span>
</span><span id="line-102"></span><span>        </span><span class="hs-comment">-- They are all OutVars, and all bound in this module</span><span>
</span><span id="line-103"></span><span>      </span><span class="hs-special">,</span><span> </span><span id="seInScope"><span class="annot"><span class="annottext">SimplEnv -&gt; InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#seInScope"><span class="hs-identifier hs-var hs-var">seInScope</span></a></span></span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span>       </span><span class="hs-comment">-- OutVars only</span><span>
</span><span id="line-104"></span><span>    </span><span class="hs-special">}</span><span>
</span><span id="line-105"></span><span>
</span><span id="line-106"></span><span class="hs-keyword">data</span><span> </span><span id="SimplFloats"><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-var">SimplFloats</span></a></span></span><span>
</span><span id="line-107"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="SimplFloats"><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-var">SimplFloats</span></a></span></span><span>
</span><span id="line-108"></span><span>      </span><span class="hs-special">{</span><span> </span><span class="hs-comment">-- Ordinary let bindings</span><span>
</span><span id="line-109"></span><span>        </span><span id="sfLetFloats"><span class="annot"><span class="annottext">SimplFloats -&gt; LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfLetFloats"><span class="hs-identifier hs-var hs-var">sfLetFloats</span></a></span></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#LetFloats"><span class="hs-identifier hs-type">LetFloats</span></a></span><span>
</span><span id="line-110"></span><span>                </span><span class="hs-comment">-- See Note [LetFloats]</span><span>
</span><span id="line-111"></span><span>
</span><span id="line-112"></span><span>        </span><span class="hs-comment">-- Join points</span><span>
</span><span id="line-113"></span><span>      </span><span class="hs-special">,</span><span> </span><span id="sfJoinFloats"><span class="annot"><span class="annottext">SimplFloats -&gt; JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfJoinFloats"><span class="hs-identifier hs-var hs-var">sfJoinFloats</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#JoinFloats"><span class="hs-identifier hs-type">JoinFloats</span></a></span><span>
</span><span id="line-114"></span><span>                </span><span class="hs-comment">-- Handled separately; they don't go very far</span><span>
</span><span id="line-115"></span><span>                </span><span class="hs-comment">-- We consider these to be /inside/ sfLetFloats</span><span>
</span><span id="line-116"></span><span>                </span><span class="hs-comment">-- because join points can refer to ordinary bindings,</span><span>
</span><span id="line-117"></span><span>                </span><span class="hs-comment">-- but not vice versa</span><span>
</span><span id="line-118"></span><span>
</span><span id="line-119"></span><span>        </span><span class="hs-comment">-- Includes all variables bound by sfLetFloats and</span><span>
</span><span id="line-120"></span><span>        </span><span class="hs-comment">-- sfJoinFloats, plus at least whatever is in scope where</span><span>
</span><span id="line-121"></span><span>        </span><span class="hs-comment">-- these bindings land up.</span><span>
</span><span id="line-122"></span><span>      </span><span class="hs-special">,</span><span> </span><span id="sfInScope"><span class="annot"><span class="annottext">SimplFloats -&gt; InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfInScope"><span class="hs-identifier hs-var hs-var">sfInScope</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span>  </span><span class="hs-comment">-- All OutVars</span><span>
</span><span id="line-123"></span><span>      </span><span class="hs-special">}</span><span>
</span><span id="line-124"></span><span>
</span><span id="line-125"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680958785"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-126"></span><span>  </span><span id="local-6989586621680958778"><span class="annot"><span class="annottext">ppr :: SimplFloats -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sfLetFloats :: SimplFloats -&gt; LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfLetFloats"><span class="hs-identifier hs-var">sfLetFloats</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958776"><span class="annot"><span class="annottext">LetFloats
</span><a href="#local-6989586621680958776"><span class="hs-identifier hs-var">lf</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sfJoinFloats :: SimplFloats -&gt; JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfJoinFloats"><span class="hs-identifier hs-var">sfJoinFloats</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958775"><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958775"><span class="hs-identifier hs-var">jf</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sfInScope :: SimplFloats -&gt; InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfInScope"><span class="hs-identifier hs-var">sfInScope</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958774"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958774"><span class="hs-identifier hs-var">is</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-127"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;SimplFloats&quot;</span></span><span>
</span><span id="line-128"></span><span>      </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#braces"><span class="hs-identifier hs-var">braces</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;lets: &quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">LetFloats -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">LetFloats
</span><a href="#local-6989586621680958776"><span class="hs-identifier hs-var">lf</span></a></span><span>
</span><span id="line-129"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;joins:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">JoinFloats -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958775"><span class="hs-identifier hs-var">jf</span></a></span><span>
</span><span id="line-130"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;in_scope:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958774"><span class="hs-identifier hs-var">is</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-131"></span><span>
</span><span id="line-132"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#emptyFloats"><span class="hs-identifier hs-type">emptyFloats</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span>
</span><span id="line-133"></span><span id="emptyFloats"><span class="annot"><span class="annottext">emptyFloats :: SimplEnv -&gt; SimplFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#emptyFloats"><span class="hs-identifier hs-var hs-var">emptyFloats</span></a></span></span><span> </span><span id="local-6989586621680958769"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958769"><span class="hs-identifier hs-var">env</span></a></span></span><span>
</span><span id="line-134"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplFloats :: LetFloats -&gt; JoinFloats -&gt; InScopeSet -&gt; SimplFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sfLetFloats :: LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfLetFloats"><span class="hs-identifier hs-var">sfLetFloats</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#emptyLetFloats"><span class="hs-identifier hs-var">emptyLetFloats</span></a></span><span>
</span><span id="line-135"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sfJoinFloats :: JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfJoinFloats"><span class="hs-identifier hs-var">sfJoinFloats</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#emptyJoinFloats"><span class="hs-identifier hs-var">emptyJoinFloats</span></a></span><span>
</span><span id="line-136"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sfInScope :: InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfInScope"><span class="hs-identifier hs-var">sfInScope</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplEnv -&gt; InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#seInScope"><span class="hs-identifier hs-var hs-var">seInScope</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958769"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-137"></span><span>
</span><span id="line-138"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#pprSimplEnv"><span class="hs-identifier hs-type">pprSimplEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-139"></span><span class="hs-comment">-- Used for debugging; selective</span><span>
</span><span id="line-140"></span><span id="pprSimplEnv"><span class="annot"><span class="annottext">pprSimplEnv :: SimplEnv -&gt; SDoc
</span><a href="GHC.Core.Opt.Simplify.Env.html#pprSimplEnv"><span class="hs-identifier hs-var hs-var">pprSimplEnv</span></a></span></span><span> </span><span id="local-6989586621680958768"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958768"><span class="hs-identifier hs-var">env</span></a></span></span><span>
</span><span id="line-141"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;TvSubst:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SimplEnv -&gt; TvSubstEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#seTvSubst"><span class="hs-identifier hs-var hs-var">seTvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958768"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-142"></span><span>          </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;CvSubst:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SimplEnv -&gt; CvSubstEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#seCvSubst"><span class="hs-identifier hs-var hs-var">seCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958768"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-143"></span><span>          </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;IdSubst:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621680958767"><span class="hs-identifier hs-var">id_subst_doc</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-144"></span><span>          </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;InScope:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621680958766"><span class="hs-identifier hs-var">in_scope_vars_doc</span></a></span><span>
</span><span id="line-145"></span><span>    </span><span class="hs-special">]</span><span>
</span><span id="line-146"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-147"></span><span>   </span><span id="local-6989586621680958767"><span class="annot"><span class="annottext">id_subst_doc :: SDoc
</span><a href="#local-6989586621680958767"><span class="hs-identifier hs-var hs-var">id_subst_doc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(SimplSR -&gt; SDoc) -&gt; SimplIdSubst -&gt; SDoc
forall a key. (a -&gt; SDoc) -&gt; UniqFM key a -&gt; SDoc
</span><a href="GHC.Types.Unique.FM.html#pprUniqFM"><span class="hs-identifier hs-var">pprUniqFM</span></a></span><span> </span><span class="annot"><span class="annottext">SimplSR -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SimplEnv -&gt; SimplIdSubst
</span><a href="GHC.Core.Opt.Simplify.Env.html#seIdSubst"><span class="hs-identifier hs-var hs-var">seIdSubst</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958768"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-148"></span><span>   </span><span id="local-6989586621680958766"><span class="annot"><span class="annottext">in_scope_vars_doc :: SDoc
</span><a href="#local-6989586621680958766"><span class="hs-identifier hs-var hs-var">in_scope_vars_doc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; ([InBndr] -&gt; SDoc) -&gt; SDoc
</span><a href="GHC.Types.Var.Set.html#pprVarSet"><span class="hs-identifier hs-var">pprVarSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; VarSet
</span><a href="GHC.Types.Var.Env.html#getInScopeVars"><span class="hs-identifier hs-var">getInScopeVars</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SimplEnv -&gt; InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#seInScope"><span class="hs-identifier hs-var hs-var">seInScope</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958768"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-149"></span><span>                                 </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="annot"><span class="annottext">([SDoc] -&gt; SDoc) -&gt; ([InBndr] -&gt; [SDoc]) -&gt; [InBndr] -&gt; SDoc
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(InBndr -&gt; SDoc) -&gt; [InBndr] -&gt; [SDoc]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr -&gt; SDoc
</span><a href="#local-6989586621680958761"><span class="hs-identifier hs-var">ppr_one</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-150"></span><span>   </span><span id="local-6989586621680958761"><span class="annot"><span class="annottext">ppr_one :: InBndr -&gt; SDoc
</span><a href="#local-6989586621680958761"><span class="hs-identifier hs-var hs-var">ppr_one</span></a></span></span><span> </span><span id="local-6989586621680958756"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958756"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">InBndr -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958756"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InBndr -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958756"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Unfolding -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InBndr -&gt; Unfolding
</span><a href="GHC.Types.Id.html#idUnfolding"><span class="hs-identifier hs-var">idUnfolding</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958756"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-151"></span><span>             </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InBndr -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958756"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-152"></span><span>
</span><span id="line-153"></span><span class="hs-keyword">type</span><span> </span><span id="SimplIdSubst"><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplIdSubst"><span class="hs-identifier hs-var">SimplIdSubst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#IdEnv"><span class="hs-identifier hs-type">IdEnv</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplSR"><span class="hs-identifier hs-type">SimplSR</span></a></span><span> </span><span class="hs-comment">-- IdId |--&gt; OutExpr</span><span>
</span><span id="line-154"></span><span>        </span><span class="hs-comment">-- See Note [Extending the Subst] in GHC.Core.Subst</span><span>
</span><span id="line-155"></span><span>
</span><span id="line-156"></span><span class="hs-comment">-- | A substitution result.</span><span>
</span><span id="line-157"></span><span class="hs-keyword">data</span><span> </span><span id="SimplSR"><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplSR"><span class="hs-identifier hs-var">SimplSR</span></a></span></span><span>
</span><span id="line-158"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="DoneEx"><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#DoneEx"><span class="hs-identifier hs-var">DoneEx</span></a></span></span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#JoinArity"><span class="hs-identifier hs-type">JoinArity</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-159"></span><span>       </span><span class="hs-comment">-- If  x :-&gt; DoneEx e ja   is in the SimplIdSubst</span><span>
</span><span id="line-160"></span><span>       </span><span class="hs-comment">-- then replace occurrences of x by e</span><span>
</span><span id="line-161"></span><span>       </span><span class="hs-comment">-- and  ja = Just a &lt;=&gt; x is a join-point of arity a</span><span>
</span><span id="line-162"></span><span>       </span><span class="hs-comment">-- See Note [Join arity in SimplIdSubst]</span><span>
</span><span id="line-163"></span><span>
</span><span id="line-164"></span><span>
</span><span id="line-165"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="DoneId"><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#DoneId"><span class="hs-identifier hs-var">DoneId</span></a></span></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span>
</span><span id="line-166"></span><span>       </span><span class="hs-comment">-- If  x :-&gt; DoneId v   is in the SimplIdSubst</span><span>
</span><span id="line-167"></span><span>       </span><span class="hs-comment">-- then replace occurrences of x by v</span><span>
</span><span id="line-168"></span><span>       </span><span class="hs-comment">-- and  v is a join-point of arity a</span><span>
</span><span id="line-169"></span><span>       </span><span class="hs-comment">--      &lt;=&gt; x is a join-point of arity a</span><span>
</span><span id="line-170"></span><span>
</span><span id="line-171"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="ContEx"><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#ContEx"><span class="hs-identifier hs-var">ContEx</span></a></span></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TvSubstEnv"><span class="hs-identifier hs-type">TvSubstEnv</span></a></span><span>                 </span><span class="hs-comment">-- A suspended substitution</span><span>
</span><span id="line-172"></span><span>           </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#CvSubstEnv"><span class="hs-identifier hs-type">CvSubstEnv</span></a></span><span>
</span><span id="line-173"></span><span>           </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplIdSubst"><span class="hs-identifier hs-type">SimplIdSubst</span></a></span><span>
</span><span id="line-174"></span><span>           </span><span class="annot"><a href="GHC.Core.html#InExpr"><span class="hs-identifier hs-type">InExpr</span></a></span><span>
</span><span id="line-175"></span><span>      </span><span class="hs-comment">-- If   x :-&gt; ContEx tv cv id e   is in the SimplISubst</span><span>
</span><span id="line-176"></span><span>      </span><span class="hs-comment">-- then replace occurrences of x by (subst (tv,cv,id) e)</span><span>
</span><span id="line-177"></span><span>
</span><span id="line-178"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680958745"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplSR"><span class="hs-identifier hs-type">SimplSR</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-179"></span><span>  </span><span id="local-6989586621680958740"><span class="annot"><span class="annottext">ppr :: SimplSR -&gt; SDoc
</span><a href="#local-6989586621680958740"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#DoneId"><span class="hs-identifier hs-type">DoneId</span></a></span><span> </span><span id="local-6989586621680958739"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958739"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;DoneId&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958739"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-180"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#DoneEx"><span class="hs-identifier hs-type">DoneEx</span></a></span><span> </span><span id="local-6989586621680958738"><span class="annot"><span class="annottext">OutExpr
</span><a href="#local-6989586621680958738"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span id="local-6989586621680958737"><span class="annot"><span class="annottext">Maybe JoinArity
</span><a href="#local-6989586621680958737"><span class="hs-identifier hs-var">mj</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;DoneEx&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621680958735"><span class="hs-identifier hs-var">pp_mj</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">OutExpr -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">OutExpr
</span><a href="#local-6989586621680958738"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-181"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-182"></span><span>      </span><span id="local-6989586621680958735"><span class="annot"><span class="annottext">pp_mj :: SDoc
</span><a href="#local-6989586621680958735"><span class="hs-identifier hs-var hs-var">pp_mj</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe JoinArity
</span><a href="#local-6989586621680958737"><span class="hs-identifier hs-var">mj</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-183"></span><span>                </span><span class="annot"><span class="annottext">Maybe JoinArity
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span>
</span><span id="line-184"></span><span>                </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680958733"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680958733"><span class="hs-identifier hs-var">n</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#int"><span class="hs-identifier hs-var">int</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680958733"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-185"></span><span>
</span><span id="line-186"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#ContEx"><span class="hs-identifier hs-type">ContEx</span></a></span><span> </span><span id="local-6989586621680958730"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680958730"><span class="hs-identifier hs-var">_tv</span></a></span></span><span> </span><span id="local-6989586621680958729"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680958729"><span class="hs-identifier hs-var">_cv</span></a></span></span><span> </span><span id="local-6989586621680958728"><span class="annot"><span class="annottext">SimplIdSubst
</span><a href="#local-6989586621680958728"><span class="hs-identifier hs-var">_id</span></a></span></span><span> </span><span id="local-6989586621680958727"><span class="annot"><span class="annottext">OutExpr
</span><a href="#local-6989586621680958727"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ContEx&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">OutExpr -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">OutExpr
</span><a href="#local-6989586621680958727"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="hs-comment">{-,
                                ppr (filter_env tv), ppr (filter_env id) -}</span><span class="hs-special">]</span><span>
</span><span id="line-188"></span><span>        </span><span class="hs-comment">-- where</span><span>
</span><span id="line-189"></span><span>        </span><span class="hs-comment">-- fvs = exprFreeVars e</span><span>
</span><span id="line-190"></span><span>        </span><span class="hs-comment">-- filter_env env = filterVarEnv_Directly keep env</span><span>
</span><span id="line-191"></span><span>        </span><span class="hs-comment">-- keep uniq _ = uniq `elemUFM_Directly` fvs</span><span>
</span><span id="line-192"></span><span>
</span><span id="line-193"></span><span class="hs-comment">{-
Note [SimplEnv invariants]
~~~~~~~~~~~~~~~~~~~~~~~~~~
seInScope:
        The in-scope part of Subst includes *all* in-scope TyVars and Ids
        The elements of the set may have better IdInfo than the
        occurrences of in-scope Ids, and (more important) they will
        have a correctly-substituted type.  So we use a lookup in this
        set to replace occurrences

        The Ids in the InScopeSet are replete with their Rules,
        and as we gather info about the unfolding of an Id, we replace
        it in the in-scope set.

        The in-scope set is actually a mapping OutVar -&gt; OutVar, and
        in case expressions we sometimes bind

seIdSubst:
        The substitution is *apply-once* only, because InIds and OutIds
        can overlap.
        For example, we generally omit mappings
                a77 -&gt; a77
        from the substitution, when we decide not to clone a77, but it's quite
        legitimate to put the mapping in the substitution anyway.

        Furthermore, consider
                let x = case k of I# x77 -&gt; ... in
                let y = case k of I# x77 -&gt; ... in ...
        and suppose the body is strict in both x and y.  Then the simplifier
        will pull the first (case k) to the top; so the second (case k) will
        cancel out, mapping x77 to, well, x77!  But one is an in-Id and the
        other is an out-Id.

        Of course, the substitution *must* applied! Things in its domain
        simply aren't necessarily bound in the result.

* substId adds a binding (DoneId new_id) to the substitution if
        the Id's unique has changed

  Note, though that the substitution isn't necessarily extended
  if the type of the Id changes.  Why not?  Because of the next point:

* We *always, always* finish by looking up in the in-scope set
  any variable that doesn't get a DoneEx or DoneVar hit in the substitution.
  Reason: so that we never finish up with a &quot;old&quot; Id in the result.
  An old Id might point to an old unfolding and so on... which gives a space
  leak.

  [The DoneEx and DoneVar hits map to &quot;new&quot; stuff.]

* It follows that substExpr must not do a no-op if the substitution is empty.
  substType is free to do so, however.

* When we come to a let-binding (say) we generate new IdInfo, including an
  unfolding, attach it to the binder, and add this newly adorned binder to
  the in-scope set.  So all subsequent occurrences of the binder will get
  mapped to the full-adorned binder, which is also the one put in the
  binding site.

* The in-scope &quot;set&quot; usually maps x-&gt;x; we use it simply for its domain.
  But sometimes we have two in-scope Ids that are synomyms, and should
  map to the same target:  x-&gt;x, y-&gt;x.  Notably:
        case y of x { ... }
  That's why the &quot;set&quot; is actually a VarEnv Var

Note [Join arity in SimplIdSubst]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We have to remember which incoming variables are join points: the occurrences
may not be marked correctly yet, and we're in change of propagating the change if
OccurAnal makes something a join point).

Normally the in-scope set is where we keep the latest information, but
the in-scope set tracks only OutVars; if a binding is unconditionally
inlined (via DoneEx), it never makes it into the in-scope set, and we
need to know at the occurrence site that the variable is a join point
so that we know to drop the context. Thus we remember which join
points we're substituting. -}</span><span>
</span><span id="line-270"></span><span>
</span><span id="line-271"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#mkSimplEnv"><span class="hs-identifier hs-type">mkSimplEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Monad.html#SimplMode"><span class="hs-identifier hs-type">SimplMode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span>
</span><span id="line-272"></span><span id="mkSimplEnv"><span class="annot"><span class="annottext">mkSimplEnv :: SimplMode -&gt; SimplEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#mkSimplEnv"><span class="hs-identifier hs-var hs-var">mkSimplEnv</span></a></span></span><span> </span><span id="local-6989586621680958726"><span class="annot"><span class="annottext">SimplMode
</span><a href="#local-6989586621680958726"><span class="hs-identifier hs-var">mode</span></a></span></span><span>
</span><span id="line-273"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplEnv :: SimplMode
-&gt; TvSubstEnv
-&gt; CvSubstEnv
-&gt; SimplIdSubst
-&gt; InScopeSet
-&gt; SimplEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">seMode :: SimplMode
</span><a href="GHC.Core.Opt.Simplify.Env.html#seMode"><span class="hs-identifier hs-var">seMode</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplMode
</span><a href="#local-6989586621680958726"><span class="hs-identifier hs-var">mode</span></a></span><span>
</span><span id="line-274"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">seInScope :: InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#seInScope"><span class="hs-identifier hs-var">seInScope</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#init_in_scope"><span class="hs-identifier hs-var">init_in_scope</span></a></span><span>
</span><span id="line-275"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">seTvSubst :: TvSubstEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#seTvSubst"><span class="hs-identifier hs-var">seTvSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span>
</span><span id="line-276"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">seCvSubst :: CvSubstEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#seCvSubst"><span class="hs-identifier hs-var">seCvSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span>
</span><span id="line-277"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">seIdSubst :: SimplIdSubst
</span><a href="GHC.Core.Opt.Simplify.Env.html#seIdSubst"><span class="hs-identifier hs-var">seIdSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplIdSubst
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-278"></span><span>        </span><span class="hs-comment">-- The top level &quot;enclosing CC&quot; is &quot;SUBSUMED&quot;.</span><span>
</span><span id="line-279"></span><span>
</span><span id="line-280"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#init_in_scope"><span class="hs-identifier hs-type">init_in_scope</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span>
</span><span id="line-281"></span><span id="init_in_scope"><span class="annot"><span class="annottext">init_in_scope :: InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#init_in_scope"><span class="hs-identifier hs-var hs-var">init_in_scope</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#mkInScopeSet"><span class="hs-identifier hs-var">mkInScopeSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InBndr -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unitVarSet"><span class="hs-identifier hs-var">unitVarSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; InBndr
</span><a href="GHC.Core.Make.html#mkWildValBinder"><span class="hs-identifier hs-var">mkWildValBinder</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Core.Type.html#Many"><span class="hs-identifier hs-var">Many</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.html#unitTy"><span class="hs-identifier hs-var">unitTy</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-282"></span><span>              </span><span class="hs-comment">-- See Note [WildCard binders]</span><span>
</span><span id="line-283"></span><span>
</span><span id="line-284"></span><span class="hs-comment">{-
Note [WildCard binders]
~~~~~~~~~~~~~~~~~~~~~~~
The program to be simplified may have wild binders
    case e of wild { p -&gt; ... }
We want to *rename* them away, so that there are no
occurrences of 'wild-id' (with wildCardKey).  The easy
way to do that is to start of with a representative
Id in the in-scope set

There can be *occurrences* of wild-id.  For example,
GHC.Core.Make.mkCoreApp transforms
   e (a /# b)   --&gt;   case (a /# b) of wild { DEFAULT -&gt; e wild }
This is ok provided 'wild' isn't free in 'e', and that's the delicate
thing. Generally, you want to run the simplifier to get rid of the
wild-ids before doing much else.

It's a very dark corner of GHC.  Maybe it should be cleaned up.
-}</span><span>
</span><span id="line-303"></span><span>
</span><span id="line-304"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#getMode"><span class="hs-identifier hs-type">getMode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Monad.html#SimplMode"><span class="hs-identifier hs-type">SimplMode</span></a></span><span>
</span><span id="line-305"></span><span id="getMode"><span class="annot"><span class="annottext">getMode :: SimplEnv -&gt; SimplMode
</span><a href="GHC.Core.Opt.Simplify.Env.html#getMode"><span class="hs-identifier hs-var hs-var">getMode</span></a></span></span><span> </span><span id="local-6989586621680958719"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958719"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplEnv -&gt; SimplMode
</span><a href="GHC.Core.Opt.Simplify.Env.html#seMode"><span class="hs-identifier hs-var hs-var">seMode</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958719"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-306"></span><span>
</span><span id="line-307"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#seDynFlags"><span class="hs-identifier hs-type">seDynFlags</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span>
</span><span id="line-308"></span><span id="seDynFlags"><span class="annot"><span class="annottext">seDynFlags :: SimplEnv -&gt; DynFlags
</span><a href="GHC.Core.Opt.Simplify.Env.html#seDynFlags"><span class="hs-identifier hs-var hs-var">seDynFlags</span></a></span></span><span> </span><span id="local-6989586621680958718"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958718"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplMode -&gt; DynFlags
</span><a href="GHC.Core.Opt.Monad.html#sm_dflags"><span class="hs-identifier hs-var hs-var">sm_dflags</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SimplEnv -&gt; SimplMode
</span><a href="GHC.Core.Opt.Simplify.Env.html#seMode"><span class="hs-identifier hs-var hs-var">seMode</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958718"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-309"></span><span>
</span><span id="line-310"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#setMode"><span class="hs-identifier hs-type">setMode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Monad.html#SimplMode"><span class="hs-identifier hs-type">SimplMode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span>
</span><span id="line-311"></span><span id="setMode"><span class="annot"><span class="annottext">setMode :: SimplMode -&gt; SimplEnv -&gt; SimplEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#setMode"><span class="hs-identifier hs-var hs-var">setMode</span></a></span></span><span> </span><span id="local-6989586621680958716"><span class="annot"><span class="annottext">SimplMode
</span><a href="#local-6989586621680958716"><span class="hs-identifier hs-var">mode</span></a></span></span><span> </span><span id="local-6989586621680958715"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958715"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958715"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">seMode :: SimplMode
</span><a href="GHC.Core.Opt.Simplify.Env.html#seMode"><span class="hs-identifier hs-var">seMode</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplMode
</span><a href="#local-6989586621680958716"><span class="hs-identifier hs-var">mode</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-312"></span><span>
</span><span id="line-313"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#updMode"><span class="hs-identifier hs-type">updMode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Monad.html#SimplMode"><span class="hs-identifier hs-type">SimplMode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Monad.html#SimplMode"><span class="hs-identifier hs-type">SimplMode</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span>
</span><span id="line-314"></span><span id="updMode"><span class="annot"><span class="annottext">updMode :: (SimplMode -&gt; SimplMode) -&gt; SimplEnv -&gt; SimplEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#updMode"><span class="hs-identifier hs-var hs-var">updMode</span></a></span></span><span> </span><span id="local-6989586621680958714"><span class="annot"><span class="annottext">SimplMode -&gt; SimplMode
</span><a href="#local-6989586621680958714"><span class="hs-identifier hs-var">upd</span></a></span></span><span> </span><span id="local-6989586621680958713"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958713"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958713"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">seMode :: SimplMode
</span><a href="GHC.Core.Opt.Simplify.Env.html#seMode"><span class="hs-identifier hs-var">seMode</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplMode -&gt; SimplMode
</span><a href="#local-6989586621680958714"><span class="hs-identifier hs-var">upd</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SimplEnv -&gt; SimplMode
</span><a href="GHC.Core.Opt.Simplify.Env.html#seMode"><span class="hs-identifier hs-var hs-var">seMode</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958713"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-315"></span><span>
</span><span id="line-316"></span><span class="hs-comment">---------------------</span><span>
</span><span id="line-317"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#extendIdSubst"><span class="hs-identifier hs-type">extendIdSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplSR"><span class="hs-identifier hs-type">SimplSR</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span>
</span><span id="line-318"></span><span id="extendIdSubst"><span class="annot"><span class="annottext">extendIdSubst :: SimplEnv -&gt; InBndr -&gt; SimplSR -&gt; SimplEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#extendIdSubst"><span class="hs-identifier hs-var hs-var">extendIdSubst</span></a></span></span><span> </span><span id="local-6989586621680958711"><span class="annot"><span class="annottext">env :: SimplEnv
</span><a href="#local-6989586621680958711"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">seIdSubst :: SimplEnv -&gt; SimplIdSubst
</span><a href="GHC.Core.Opt.Simplify.Env.html#seIdSubst"><span class="hs-identifier hs-var">seIdSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958710"><span class="annot"><span class="annottext">SimplIdSubst
</span><a href="#local-6989586621680958710"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680958709"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958709"><span class="hs-identifier hs-var">var</span></a></span></span><span> </span><span id="local-6989586621680958708"><span class="annot"><span class="annottext">SimplSR
</span><a href="#local-6989586621680958708"><span class="hs-identifier hs-var">res</span></a></span></span><span>
</span><span id="line-319"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isId</span><span> </span><span class="hs-identifier">var</span><span> </span><span class="hs-operator">&amp;&amp;</span><span> </span><span class="hs-identifier">not</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">isCoVar</span><span> </span><span class="hs-identifier">var</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">var</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-320"></span><span>    </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958711"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">seIdSubst :: SimplIdSubst
</span><a href="GHC.Core.Opt.Simplify.Env.html#seIdSubst"><span class="hs-identifier hs-var">seIdSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplIdSubst -&gt; InBndr -&gt; SimplSR -&gt; SimplIdSubst
forall a. VarEnv a -&gt; InBndr -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">SimplIdSubst
</span><a href="#local-6989586621680958710"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958709"><span class="hs-identifier hs-var">var</span></a></span><span> </span><span class="annot"><span class="annottext">SimplSR
</span><a href="#local-6989586621680958708"><span class="hs-identifier hs-var">res</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-321"></span><span>
</span><span id="line-322"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#extendTvSubst"><span class="hs-identifier hs-type">extendTvSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span>
</span><span id="line-323"></span><span id="extendTvSubst"><span class="annot"><span class="annottext">extendTvSubst :: SimplEnv -&gt; InBndr -&gt; Type -&gt; SimplEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#extendTvSubst"><span class="hs-identifier hs-var hs-var">extendTvSubst</span></a></span></span><span> </span><span id="local-6989586621680958700"><span class="annot"><span class="annottext">env :: SimplEnv
</span><a href="#local-6989586621680958700"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">seTvSubst :: SimplEnv -&gt; TvSubstEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#seTvSubst"><span class="hs-identifier hs-var">seTvSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958699"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680958699"><span class="hs-identifier hs-var">tsubst</span></a></span></span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680958698"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958698"><span class="hs-identifier hs-var">var</span></a></span></span><span> </span><span id="local-6989586621680958697"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958697"><span class="hs-identifier hs-var">res</span></a></span></span><span>
</span><span id="line-324"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isTyVar</span><span> </span><span class="hs-identifier">var</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">var</span><span> </span><span class="hs-operator">$$</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">res</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-325"></span><span>    </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958700"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">seTvSubst :: TvSubstEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#seTvSubst"><span class="hs-identifier hs-var">seTvSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; InBndr -&gt; Type -&gt; TvSubstEnv
forall a. VarEnv a -&gt; InBndr -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680958699"><span class="hs-identifier hs-var">tsubst</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958698"><span class="hs-identifier hs-var">var</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958697"><span class="hs-identifier hs-var">res</span></a></span><span class="hs-special">}</span><span>
</span><span id="line-326"></span><span>
</span><span id="line-327"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#extendCvSubst"><span class="hs-identifier hs-type">extendCvSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span>
</span><span id="line-328"></span><span id="extendCvSubst"><span class="annot"><span class="annottext">extendCvSubst :: SimplEnv -&gt; InBndr -&gt; Coercion -&gt; SimplEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#extendCvSubst"><span class="hs-identifier hs-var hs-var">extendCvSubst</span></a></span></span><span> </span><span id="local-6989586621680958693"><span class="annot"><span class="annottext">env :: SimplEnv
</span><a href="#local-6989586621680958693"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">seCvSubst :: SimplEnv -&gt; CvSubstEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#seCvSubst"><span class="hs-identifier hs-var">seCvSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958692"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680958692"><span class="hs-identifier hs-var">csubst</span></a></span></span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680958691"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958691"><span class="hs-identifier hs-var">var</span></a></span></span><span> </span><span id="local-6989586621680958690"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680958690"><span class="hs-identifier hs-var">co</span></a></span></span><span>
</span><span id="line-329"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isCoVar</span><span> </span><span class="hs-identifier">var</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-330"></span><span>    </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958693"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">seCvSubst :: CvSubstEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#seCvSubst"><span class="hs-identifier hs-var">seCvSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; InBndr -&gt; Coercion -&gt; CvSubstEnv
forall a. VarEnv a -&gt; InBndr -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680958692"><span class="hs-identifier hs-var">csubst</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958691"><span class="hs-identifier hs-var">var</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680958690"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">}</span><span>
</span><span id="line-331"></span><span>
</span><span id="line-332"></span><span class="hs-comment">---------------------</span><span>
</span><span id="line-333"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#getInScope"><span class="hs-identifier hs-type">getInScope</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span>
</span><span id="line-334"></span><span id="getInScope"><span class="annot"><span class="annottext">getInScope :: SimplEnv -&gt; InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#getInScope"><span class="hs-identifier hs-var hs-var">getInScope</span></a></span></span><span> </span><span id="local-6989586621680958688"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958688"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplEnv -&gt; InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#seInScope"><span class="hs-identifier hs-var hs-var">seInScope</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958688"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-335"></span><span>
</span><span id="line-336"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#setInScopeSet"><span class="hs-identifier hs-type">setInScopeSet</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span>
</span><span id="line-337"></span><span id="setInScopeSet"><span class="annot"><span class="annottext">setInScopeSet :: SimplEnv -&gt; InScopeSet -&gt; SimplEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#setInScopeSet"><span class="hs-identifier hs-var hs-var">setInScopeSet</span></a></span></span><span> </span><span id="local-6989586621680958687"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958687"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680958686"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958686"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958687"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">seInScope :: InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#seInScope"><span class="hs-identifier hs-var">seInScope</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958686"><span class="hs-identifier hs-var">in_scope</span></a></span><span class="hs-special">}</span><span>
</span><span id="line-338"></span><span>
</span><span id="line-339"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#setInScopeFromE"><span class="hs-identifier hs-type">setInScopeFromE</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span>
</span><span id="line-340"></span><span class="hs-comment">-- See Note [Setting the right in-scope set]</span><span>
</span><span id="line-341"></span><span id="setInScopeFromE"><span class="annot"><span class="annottext">setInScopeFromE :: SimplEnv -&gt; SimplEnv -&gt; SimplEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#setInScopeFromE"><span class="hs-identifier hs-var hs-var">setInScopeFromE</span></a></span></span><span> </span><span id="local-6989586621680958685"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958685"><span class="hs-identifier hs-var">rhs_env</span></a></span></span><span> </span><span id="local-6989586621680958684"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958684"><span class="hs-identifier hs-var">here_env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958685"><span class="hs-identifier hs-var">rhs_env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">seInScope :: InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#seInScope"><span class="hs-identifier hs-var">seInScope</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplEnv -&gt; InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#seInScope"><span class="hs-identifier hs-var hs-var">seInScope</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958684"><span class="hs-identifier hs-var">here_env</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-342"></span><span>
</span><span id="line-343"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#setInScopeFromF"><span class="hs-identifier hs-type">setInScopeFromF</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span>
</span><span id="line-344"></span><span id="setInScopeFromF"><span class="annot"><span class="annottext">setInScopeFromF :: SimplEnv -&gt; SimplFloats -&gt; SimplEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#setInScopeFromF"><span class="hs-identifier hs-var hs-var">setInScopeFromF</span></a></span></span><span> </span><span id="local-6989586621680958683"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958683"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680958682"><span class="annot"><span class="annottext">SimplFloats
</span><a href="#local-6989586621680958682"><span class="hs-identifier hs-var">floats</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958683"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">seInScope :: InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#seInScope"><span class="hs-identifier hs-var">seInScope</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplFloats -&gt; InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfInScope"><span class="hs-identifier hs-var hs-var">sfInScope</span></a></span><span> </span><span class="annot"><span class="annottext">SimplFloats
</span><a href="#local-6989586621680958682"><span class="hs-identifier hs-var">floats</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-345"></span><span>
</span><span id="line-346"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#addNewInScopeIds"><span class="hs-identifier hs-type">addNewInScopeIds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span>
</span><span id="line-347"></span><span>        </span><span class="hs-comment">-- The new Ids are guaranteed to be freshly allocated</span><span>
</span><span id="line-348"></span><span id="addNewInScopeIds"><span class="annot"><span class="annottext">addNewInScopeIds :: SimplEnv -&gt; [InBndr] -&gt; SimplEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#addNewInScopeIds"><span class="hs-identifier hs-var hs-var">addNewInScopeIds</span></a></span></span><span> </span><span id="local-6989586621680958680"><span class="annot"><span class="annottext">env :: SimplEnv
</span><a href="#local-6989586621680958680"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">seInScope :: SimplEnv -&gt; InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#seInScope"><span class="hs-identifier hs-var">seInScope</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958679"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958679"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">seIdSubst :: SimplEnv -&gt; SimplIdSubst
</span><a href="GHC.Core.Opt.Simplify.Env.html#seIdSubst"><span class="hs-identifier hs-var">seIdSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958678"><span class="annot"><span class="annottext">SimplIdSubst
</span><a href="#local-6989586621680958678"><span class="hs-identifier hs-var">id_subst</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680958677"><span class="annot"><span class="annottext">[InBndr]
</span><a href="#local-6989586621680958677"><span class="hs-identifier hs-var">vs</span></a></span></span><span>
</span><span id="line-349"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958680"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">seInScope :: InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#seInScope"><span class="hs-identifier hs-var">seInScope</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958679"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; [InBndr] -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#extendInScopeSetList"><span class="hs-operator hs-var">`extendInScopeSetList`</span></a></span><span> </span><span class="annot"><span class="annottext">[InBndr]
</span><a href="#local-6989586621680958677"><span class="hs-identifier hs-var">vs</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-350"></span><span>          </span><span class="annot"><span class="annottext">seIdSubst :: SimplIdSubst
</span><a href="GHC.Core.Opt.Simplify.Env.html#seIdSubst"><span class="hs-identifier hs-var">seIdSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplIdSubst
</span><a href="#local-6989586621680958678"><span class="hs-identifier hs-var">id_subst</span></a></span><span> </span><span class="annot"><span class="annottext">SimplIdSubst -&gt; [InBndr] -&gt; SimplIdSubst
forall a. VarEnv a -&gt; [InBndr] -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#delVarEnvList"><span class="hs-operator hs-var">`delVarEnvList`</span></a></span><span> </span><span class="annot"><span class="annottext">[InBndr]
</span><a href="#local-6989586621680958677"><span class="hs-identifier hs-var">vs</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-351"></span><span>        </span><span class="hs-comment">-- Why delete?  Consider</span><span>
</span><span id="line-352"></span><span>        </span><span class="hs-comment">--      let x = a*b in (x, \x -&gt; x+3)</span><span>
</span><span id="line-353"></span><span>        </span><span class="hs-comment">-- We add [x |-&gt; a*b] to the substitution, but we must</span><span>
</span><span id="line-354"></span><span>        </span><span class="hs-comment">-- _delete_ it from the substitution when going inside</span><span>
</span><span id="line-355"></span><span>        </span><span class="hs-comment">-- the (\x -&gt; ...)!</span><span>
</span><span id="line-356"></span><span>
</span><span id="line-357"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#modifyInScope"><span class="hs-identifier hs-type">modifyInScope</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span>
</span><span id="line-358"></span><span class="hs-comment">-- The variable should already be in scope, but</span><span>
</span><span id="line-359"></span><span class="hs-comment">-- replace the existing version with this new one</span><span>
</span><span id="line-360"></span><span class="hs-comment">-- which has more information</span><span>
</span><span id="line-361"></span><span id="modifyInScope"><span class="annot"><span class="annottext">modifyInScope :: SimplEnv -&gt; InBndr -&gt; SimplEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#modifyInScope"><span class="hs-identifier hs-var hs-var">modifyInScope</span></a></span></span><span> </span><span id="local-6989586621680958674"><span class="annot"><span class="annottext">env :: SimplEnv
</span><a href="#local-6989586621680958674"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">seInScope :: SimplEnv -&gt; InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#seInScope"><span class="hs-identifier hs-var">seInScope</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958673"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958673"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680958672"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958672"><span class="hs-identifier hs-var">v</span></a></span></span><span>
</span><span id="line-362"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958674"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">seInScope :: InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#seInScope"><span class="hs-identifier hs-var">seInScope</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; InBndr -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#extendInScopeSet"><span class="hs-identifier hs-var">extendInScopeSet</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958673"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958672"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">}</span><span>
</span><span id="line-363"></span><span>
</span><span id="line-364"></span><span class="hs-comment">{- Note [Setting the right in-scope set]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider
  \x. (let x = e in b) arg[x]
where the let shadows the lambda.  Really this means something like
  \x1. (let x2 = e in b) arg[x1]

- When we capture the 'arg' in an ApplyToVal continuation, we capture
  the environment, which says what 'x' is bound to, namely x1

- Then that continuation gets pushed under the let

- Finally we simplify 'arg'.  We want
     - the static, lexical environment binding x :-&gt; x1
     - the in-scopeset from &quot;here&quot;, under the 'let' which includes
       both x1 and x2

It's important to have the right in-scope set, else we may rename a
variable to one that is already in scope.  So we must pick up the
in-scope set from &quot;here&quot;, but otherwise use the environment we
captured along with 'arg'.  This transfer of in-scope set is done by
setInScopeFromE.
-}</span><span>
</span><span id="line-387"></span><span>
</span><span id="line-388"></span><span class="hs-comment">---------------------</span><span>
</span><span id="line-389"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#zapSubstEnv"><span class="hs-identifier hs-type">zapSubstEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span>
</span><span id="line-390"></span><span id="zapSubstEnv"><span class="annot"><span class="annottext">zapSubstEnv :: SimplEnv -&gt; SimplEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#zapSubstEnv"><span class="hs-identifier hs-var hs-var">zapSubstEnv</span></a></span></span><span> </span><span id="local-6989586621680958670"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958670"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958670"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">seTvSubst :: TvSubstEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#seTvSubst"><span class="hs-identifier hs-var">seTvSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">seCvSubst :: CvSubstEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#seCvSubst"><span class="hs-identifier hs-var">seCvSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">seIdSubst :: SimplIdSubst
</span><a href="GHC.Core.Opt.Simplify.Env.html#seIdSubst"><span class="hs-identifier hs-var">seIdSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplIdSubst
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span class="hs-special">}</span><span>
</span><span id="line-391"></span><span>
</span><span id="line-392"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#setSubstEnv"><span class="hs-identifier hs-type">setSubstEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TvSubstEnv"><span class="hs-identifier hs-type">TvSubstEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#CvSubstEnv"><span class="hs-identifier hs-type">CvSubstEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplIdSubst"><span class="hs-identifier hs-type">SimplIdSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span>
</span><span id="line-393"></span><span id="setSubstEnv"><span class="annot"><span class="annottext">setSubstEnv :: SimplEnv -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; SimplIdSubst -&gt; SimplEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#setSubstEnv"><span class="hs-identifier hs-var hs-var">setSubstEnv</span></a></span></span><span> </span><span id="local-6989586621680958669"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958669"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680958668"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680958668"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621680958667"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680958667"><span class="hs-identifier hs-var">cvs</span></a></span></span><span> </span><span id="local-6989586621680958666"><span class="annot"><span class="annottext">SimplIdSubst
</span><a href="#local-6989586621680958666"><span class="hs-identifier hs-var">ids</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958669"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">seTvSubst :: TvSubstEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#seTvSubst"><span class="hs-identifier hs-var">seTvSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680958668"><span class="hs-identifier hs-var">tvs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">seCvSubst :: CvSubstEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#seCvSubst"><span class="hs-identifier hs-var">seCvSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680958667"><span class="hs-identifier hs-var">cvs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">seIdSubst :: SimplIdSubst
</span><a href="GHC.Core.Opt.Simplify.Env.html#seIdSubst"><span class="hs-identifier hs-var">seIdSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplIdSubst
</span><a href="#local-6989586621680958666"><span class="hs-identifier hs-var">ids</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-394"></span><span>
</span><span id="line-395"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#mkContEx"><span class="hs-identifier hs-type">mkContEx</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#InExpr"><span class="hs-identifier hs-type">InExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplSR"><span class="hs-identifier hs-type">SimplSR</span></a></span><span>
</span><span id="line-396"></span><span id="mkContEx"><span class="annot"><span class="annottext">mkContEx :: SimplEnv -&gt; OutExpr -&gt; SimplSR
</span><a href="GHC.Core.Opt.Simplify.Env.html#mkContEx"><span class="hs-identifier hs-var hs-var">mkContEx</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">seTvSubst :: SimplEnv -&gt; TvSubstEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#seTvSubst"><span class="hs-identifier hs-var">seTvSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958665"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680958665"><span class="hs-identifier hs-var">tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">seCvSubst :: SimplEnv -&gt; CvSubstEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#seCvSubst"><span class="hs-identifier hs-var">seCvSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958664"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680958664"><span class="hs-identifier hs-var">cvs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">seIdSubst :: SimplEnv -&gt; SimplIdSubst
</span><a href="GHC.Core.Opt.Simplify.Env.html#seIdSubst"><span class="hs-identifier hs-var">seIdSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958663"><span class="annot"><span class="annottext">SimplIdSubst
</span><a href="#local-6989586621680958663"><span class="hs-identifier hs-var">ids</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680958662"><span class="annot"><span class="annottext">OutExpr
</span><a href="#local-6989586621680958662"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; CvSubstEnv -&gt; SimplIdSubst -&gt; OutExpr -&gt; SimplSR
</span><a href="GHC.Core.Opt.Simplify.Env.html#ContEx"><span class="hs-identifier hs-var">ContEx</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680958665"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680958664"><span class="hs-identifier hs-var">cvs</span></a></span><span> </span><span class="annot"><span class="annottext">SimplIdSubst
</span><a href="#local-6989586621680958663"><span class="hs-identifier hs-var">ids</span></a></span><span> </span><span class="annot"><span class="annottext">OutExpr
</span><a href="#local-6989586621680958662"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-397"></span><span>
</span><span id="line-398"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
\subsection{LetFloats}
*                                                                      *
************************************************************************

Note [LetFloats]
~~~~~~~~~~~~~~~~
The LetFloats is a bunch of bindings, classified by a FloatFlag.

* All of them satisfy the let/app invariant

Examples

  NonRec x (y:ys)       FltLifted
  Rec [(x,rhs)]         FltLifted

  NonRec x* (p:q)       FltOKSpec   -- RHS is WHNF.  Question: why not FltLifted?
  NonRec x# (y +# 3)    FltOkSpec   -- Unboxed, but ok-for-spec'n

  NonRec x* (f y)       FltCareful  -- Strict binding; might fail or diverge

Can't happen:
  NonRec x# (a /# b)    -- Might fail; does not satisfy let/app
  NonRec x# (f y)       -- Might diverge; does not satisfy let/app
-}</span><span>
</span><span id="line-425"></span><span>
</span><span id="line-426"></span><span class="hs-keyword">data</span><span> </span><span id="LetFloats"><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#LetFloats"><span class="hs-identifier hs-var">LetFloats</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="LetFloats"><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#LetFloats"><span class="hs-identifier hs-var">LetFloats</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.OrdList.html#OrdList"><span class="hs-identifier hs-type">OrdList</span></a></span><span> </span><span class="annot"><a href="GHC.Core.html#OutBind"><span class="hs-identifier hs-type">OutBind</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#FloatFlag"><span class="hs-identifier hs-type">FloatFlag</span></a></span><span>
</span><span id="line-427"></span><span>                 </span><span class="hs-comment">-- See Note [LetFloats]</span><span>
</span><span id="line-428"></span><span>
</span><span id="line-429"></span><span class="hs-keyword">type</span><span> </span><span id="JoinFloat"><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#JoinFloat"><span class="hs-identifier hs-var">JoinFloat</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Core.html#OutBind"><span class="hs-identifier hs-type">OutBind</span></a></span><span>
</span><span id="line-430"></span><span class="hs-keyword">type</span><span> </span><span id="JoinFloats"><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#JoinFloats"><span class="hs-identifier hs-var">JoinFloats</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Data.OrdList.html#OrdList"><span class="hs-identifier hs-type">OrdList</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#JoinFloat"><span class="hs-identifier hs-type">JoinFloat</span></a></span><span>
</span><span id="line-431"></span><span>
</span><span id="line-432"></span><span class="hs-keyword">data</span><span> </span><span id="FloatFlag"><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#FloatFlag"><span class="hs-identifier hs-var">FloatFlag</span></a></span></span><span>
</span><span id="line-433"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="FltLifted"><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#FltLifted"><span class="hs-identifier hs-var">FltLifted</span></a></span></span><span>   </span><span class="hs-comment">-- All bindings are lifted and lazy *or*</span><span>
</span><span id="line-434"></span><span>                </span><span class="hs-comment">--     consist of a single primitive string literal</span><span>
</span><span id="line-435"></span><span>                </span><span class="hs-comment">--  Hence ok to float to top level, or recursive</span><span>
</span><span id="line-436"></span><span>
</span><span id="line-437"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="FltOkSpec"><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#FltOkSpec"><span class="hs-identifier hs-var">FltOkSpec</span></a></span></span><span>   </span><span class="hs-comment">-- All bindings are FltLifted *or*</span><span>
</span><span id="line-438"></span><span>                </span><span class="hs-comment">--      strict (perhaps because unlifted,</span><span>
</span><span id="line-439"></span><span>                </span><span class="hs-comment">--      perhaps because of a strict binder),</span><span>
</span><span id="line-440"></span><span>                </span><span class="hs-comment">--        *and* ok-for-speculation</span><span>
</span><span id="line-441"></span><span>                </span><span class="hs-comment">--  Hence ok to float out of the RHS</span><span>
</span><span id="line-442"></span><span>                </span><span class="hs-comment">--  of a lazy non-recursive let binding</span><span>
</span><span id="line-443"></span><span>                </span><span class="hs-comment">--  (but not to top level, or into a rec group)</span><span>
</span><span id="line-444"></span><span>
</span><span id="line-445"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="FltCareful"><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#FltCareful"><span class="hs-identifier hs-var">FltCareful</span></a></span></span><span>  </span><span class="hs-comment">-- At least one binding is strict (or unlifted)</span><span>
</span><span id="line-446"></span><span>                </span><span class="hs-comment">--      and not guaranteed cheap</span><span>
</span><span id="line-447"></span><span>                </span><span class="hs-comment">--      Do not float these bindings out of a lazy let</span><span>
</span><span id="line-448"></span><span>
</span><span id="line-449"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680958655"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#LetFloats"><span class="hs-identifier hs-type">LetFloats</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-450"></span><span>  </span><span id="local-6989586621680958652"><span class="annot"><span class="annottext">ppr :: LetFloats -&gt; SDoc
</span><a href="#local-6989586621680958652"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#LetFloats"><span class="hs-identifier hs-type">LetFloats</span></a></span><span> </span><span id="local-6989586621680958651"><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958651"><span class="hs-identifier hs-var">binds</span></a></span></span><span> </span><span id="local-6989586621680958650"><span class="annot"><span class="annottext">FloatFlag
</span><a href="#local-6989586621680958650"><span class="hs-identifier hs-var">ff</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FloatFlag -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">FloatFlag
</span><a href="#local-6989586621680958650"><span class="hs-identifier hs-var">ff</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">[OutBind] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinFloats -&gt; [OutBind]
forall a. OrdList a -&gt; [a]
</span><a href="GHC.Data.OrdList.html#fromOL"><span class="hs-identifier hs-var">fromOL</span></a></span><span> </span><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958651"><span class="hs-identifier hs-var">binds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-451"></span><span>
</span><span id="line-452"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680958646"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#FloatFlag"><span class="hs-identifier hs-type">FloatFlag</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-453"></span><span>  </span><span id="local-6989586621680958645"><span class="annot"><span class="annottext">ppr :: FloatFlag -&gt; SDoc
</span><a href="#local-6989586621680958645"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="annot"><span class="annottext">FloatFlag
</span><a href="GHC.Core.Opt.Simplify.Env.html#FltLifted"><span class="hs-identifier hs-var">FltLifted</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;FltLifted&quot;</span></span><span>
</span><span id="line-454"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">FloatFlag
</span><a href="GHC.Core.Opt.Simplify.Env.html#FltOkSpec"><span class="hs-identifier hs-var">FltOkSpec</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;FltOkSpec&quot;</span></span><span>
</span><span id="line-455"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">FloatFlag
</span><a href="GHC.Core.Opt.Simplify.Env.html#FltCareful"><span class="hs-identifier hs-var">FltCareful</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;FltCareful&quot;</span></span><span>
</span><span id="line-456"></span><span>
</span><span id="line-457"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#andFF"><span class="hs-identifier hs-type">andFF</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#FloatFlag"><span class="hs-identifier hs-type">FloatFlag</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#FloatFlag"><span class="hs-identifier hs-type">FloatFlag</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#FloatFlag"><span class="hs-identifier hs-type">FloatFlag</span></a></span><span>
</span><span id="line-458"></span><span id="andFF"><span class="annot"><span class="annottext">andFF :: FloatFlag -&gt; FloatFlag -&gt; FloatFlag
</span><a href="GHC.Core.Opt.Simplify.Env.html#andFF"><span class="hs-identifier hs-var hs-var">andFF</span></a></span></span><span> </span><span class="annot"><span class="annottext">FloatFlag
</span><a href="GHC.Core.Opt.Simplify.Env.html#FltCareful"><span class="hs-identifier hs-var">FltCareful</span></a></span><span> </span><span class="annot"><span class="annottext">FloatFlag
</span><span class="hs-identifier">_</span></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FloatFlag
</span><a href="GHC.Core.Opt.Simplify.Env.html#FltCareful"><span class="hs-identifier hs-var">FltCareful</span></a></span><span>
</span><span id="line-459"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#andFF"><span class="hs-identifier hs-var">andFF</span></a></span><span> </span><span class="annot"><span class="annottext">FloatFlag
</span><a href="GHC.Core.Opt.Simplify.Env.html#FltOkSpec"><span class="hs-identifier hs-var">FltOkSpec</span></a></span><span>  </span><span class="annot"><span class="annottext">FloatFlag
</span><a href="GHC.Core.Opt.Simplify.Env.html#FltCareful"><span class="hs-identifier hs-var">FltCareful</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FloatFlag
</span><a href="GHC.Core.Opt.Simplify.Env.html#FltCareful"><span class="hs-identifier hs-var">FltCareful</span></a></span><span>
</span><span id="line-460"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#andFF"><span class="hs-identifier hs-var">andFF</span></a></span><span> </span><span class="annot"><span class="annottext">FloatFlag
</span><a href="GHC.Core.Opt.Simplify.Env.html#FltOkSpec"><span class="hs-identifier hs-var">FltOkSpec</span></a></span><span>  </span><span class="annot"><span class="annottext">FloatFlag
</span><span class="hs-identifier">_</span></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FloatFlag
</span><a href="GHC.Core.Opt.Simplify.Env.html#FltOkSpec"><span class="hs-identifier hs-var">FltOkSpec</span></a></span><span>
</span><span id="line-461"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#andFF"><span class="hs-identifier hs-var">andFF</span></a></span><span> </span><span class="annot"><span class="annottext">FloatFlag
</span><a href="GHC.Core.Opt.Simplify.Env.html#FltLifted"><span class="hs-identifier hs-var">FltLifted</span></a></span><span>  </span><span id="local-6989586621680958643"><span class="annot"><span class="annottext">FloatFlag
</span><a href="#local-6989586621680958643"><span class="hs-identifier hs-var">flt</span></a></span></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FloatFlag
</span><a href="#local-6989586621680958643"><span class="hs-identifier hs-var">flt</span></a></span><span>
</span><span id="line-462"></span><span>
</span><span id="line-463"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#doFloatFromRhs"><span class="hs-identifier hs-type">doFloatFromRhs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TopLevelFlag"><span class="hs-identifier hs-type">TopLevelFlag</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#RecFlag"><span class="hs-identifier hs-type">RecFlag</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-464"></span><span class="hs-comment">-- If you change this function look also at FloatIn.noFloatFromRhs</span><span>
</span><span id="line-465"></span><span id="doFloatFromRhs"><span class="annot"><span class="annottext">doFloatFromRhs :: TopLevelFlag -&gt; RecFlag -&gt; Bool -&gt; SimplFloats -&gt; OutExpr -&gt; Bool
</span><a href="GHC.Core.Opt.Simplify.Env.html#doFloatFromRhs"><span class="hs-identifier hs-var hs-var">doFloatFromRhs</span></a></span></span><span> </span><span id="local-6989586621680958642"><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680958642"><span class="hs-identifier hs-var">lvl</span></a></span></span><span> </span><span id="local-6989586621680958641"><span class="annot"><span class="annottext">RecFlag
</span><a href="#local-6989586621680958641"><span class="hs-identifier hs-var">rec</span></a></span></span><span> </span><span id="local-6989586621680958640"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680958640"><span class="hs-identifier hs-var">str</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sfLetFloats :: SimplFloats -&gt; LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfLetFloats"><span class="hs-identifier hs-var">sfLetFloats</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#LetFloats"><span class="hs-identifier hs-type">LetFloats</span></a></span><span> </span><span id="local-6989586621680958639"><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958639"><span class="hs-identifier hs-var">fs</span></a></span></span><span> </span><span id="local-6989586621680958638"><span class="annot"><span class="annottext">FloatFlag
</span><a href="#local-6989586621680958638"><span class="hs-identifier hs-var">ff</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680958637"><span class="annot"><span class="annottext">OutExpr
</span><a href="#local-6989586621680958637"><span class="hs-identifier hs-var">rhs</span></a></span></span><span>
</span><span id="line-466"></span><span>  </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinFloats -&gt; Bool
forall a. OrdList a -&gt; Bool
</span><a href="GHC.Data.OrdList.html#isNilOL"><span class="hs-identifier hs-var">isNilOL</span></a></span><span> </span><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958639"><span class="hs-identifier hs-var">fs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680958635"><span class="hs-identifier hs-var">want_to_float</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680958634"><span class="hs-identifier hs-var">can_float</span></a></span><span>
</span><span id="line-467"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-468"></span><span>     </span><span id="local-6989586621680958635"><span class="annot"><span class="annottext">want_to_float :: Bool
</span><a href="#local-6989586621680958635"><span class="hs-identifier hs-var hs-var">want_to_float</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TopLevelFlag -&gt; Bool
</span><a href="GHC.Types.Basic.html#isTopLevel"><span class="hs-identifier hs-var">isTopLevel</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680958642"><span class="hs-identifier hs-var">lvl</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">OutExpr -&gt; Bool
</span><a href="GHC.Core.Utils.html#exprIsCheap"><span class="hs-identifier hs-var">exprIsCheap</span></a></span><span> </span><span class="annot"><span class="annottext">OutExpr
</span><a href="#local-6989586621680958637"><span class="hs-identifier hs-var">rhs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">OutExpr -&gt; Bool
</span><a href="GHC.Core.Utils.html#exprIsExpandable"><span class="hs-identifier hs-var">exprIsExpandable</span></a></span><span> </span><span class="annot"><span class="annottext">OutExpr
</span><a href="#local-6989586621680958637"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-469"></span><span>                     </span><span class="hs-comment">-- See Note [Float when cheap or expandable]</span><span>
</span><span id="line-470"></span><span>     </span><span id="local-6989586621680958634"><span class="annot"><span class="annottext">can_float :: Bool
</span><a href="#local-6989586621680958634"><span class="hs-identifier hs-var hs-var">can_float</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">FloatFlag
</span><a href="#local-6989586621680958638"><span class="hs-identifier hs-var">ff</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-471"></span><span>                   </span><span class="annot"><span class="annottext">FloatFlag
</span><a href="GHC.Core.Opt.Simplify.Env.html#FltLifted"><span class="hs-identifier hs-var">FltLifted</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-472"></span><span>                   </span><span class="annot"><span class="annottext">FloatFlag
</span><a href="GHC.Core.Opt.Simplify.Env.html#FltOkSpec"><span class="hs-identifier hs-var">FltOkSpec</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TopLevelFlag -&gt; Bool
</span><a href="GHC.Types.Basic.html#isNotTopLevel"><span class="hs-identifier hs-var">isNotTopLevel</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680958642"><span class="hs-identifier hs-var">lvl</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">RecFlag -&gt; Bool
</span><a href="GHC.Types.Basic.html#isNonRec"><span class="hs-identifier hs-var">isNonRec</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="#local-6989586621680958641"><span class="hs-identifier hs-var">rec</span></a></span><span>
</span><span id="line-473"></span><span>                   </span><span class="annot"><span class="annottext">FloatFlag
</span><a href="GHC.Core.Opt.Simplify.Env.html#FltCareful"><span class="hs-identifier hs-var">FltCareful</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TopLevelFlag -&gt; Bool
</span><a href="GHC.Types.Basic.html#isNotTopLevel"><span class="hs-identifier hs-var">isNotTopLevel</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680958642"><span class="hs-identifier hs-var">lvl</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">RecFlag -&gt; Bool
</span><a href="GHC.Types.Basic.html#isNonRec"><span class="hs-identifier hs-var">isNonRec</span></a></span><span> </span><span class="annot"><span class="annottext">RecFlag
</span><a href="#local-6989586621680958641"><span class="hs-identifier hs-var">rec</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680958640"><span class="hs-identifier hs-var">str</span></a></span><span>
</span><span id="line-474"></span><span>
</span><span id="line-475"></span><span class="hs-comment">{-
Note [Float when cheap or expandable]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We want to float a let from a let if the residual RHS is
   a) cheap, such as (\x. blah)
   b) expandable, such as (f b) if f is CONLIKE
But there are
  - cheap things that are not expandable (eg \x. expensive)
  - expandable things that are not cheap (eg (f b) where b is CONLIKE)
so we must take the 'or' of the two.
-}</span><span>
</span><span id="line-486"></span><span>
</span><span id="line-487"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#emptyLetFloats"><span class="hs-identifier hs-type">emptyLetFloats</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#LetFloats"><span class="hs-identifier hs-type">LetFloats</span></a></span><span>
</span><span id="line-488"></span><span id="emptyLetFloats"><span class="annot"><span class="annottext">emptyLetFloats :: LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#emptyLetFloats"><span class="hs-identifier hs-var hs-var">emptyLetFloats</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinFloats -&gt; FloatFlag -&gt; LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#LetFloats"><span class="hs-identifier hs-var">LetFloats</span></a></span><span> </span><span class="annot"><span class="annottext">JoinFloats
forall a. OrdList a
</span><a href="GHC.Data.OrdList.html#nilOL"><span class="hs-identifier hs-var">nilOL</span></a></span><span> </span><span class="annot"><span class="annottext">FloatFlag
</span><a href="GHC.Core.Opt.Simplify.Env.html#FltLifted"><span class="hs-identifier hs-var">FltLifted</span></a></span><span>
</span><span id="line-489"></span><span>
</span><span id="line-490"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#emptyJoinFloats"><span class="hs-identifier hs-type">emptyJoinFloats</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#JoinFloats"><span class="hs-identifier hs-type">JoinFloats</span></a></span><span>
</span><span id="line-491"></span><span id="emptyJoinFloats"><span class="annot"><span class="annottext">emptyJoinFloats :: JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#emptyJoinFloats"><span class="hs-identifier hs-var hs-var">emptyJoinFloats</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinFloats
forall a. OrdList a
</span><a href="GHC.Data.OrdList.html#nilOL"><span class="hs-identifier hs-var">nilOL</span></a></span><span>
</span><span id="line-492"></span><span>
</span><span id="line-493"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#unitLetFloat"><span class="hs-identifier hs-type">unitLetFloat</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.html#OutBind"><span class="hs-identifier hs-type">OutBind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#LetFloats"><span class="hs-identifier hs-type">LetFloats</span></a></span><span>
</span><span id="line-494"></span><span class="hs-comment">-- This key function constructs a singleton float with the right form</span><span>
</span><span id="line-495"></span><span id="unitLetFloat"><span class="annot"><span class="annottext">unitLetFloat :: OutBind -&gt; LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#unitLetFloat"><span class="hs-identifier hs-var hs-var">unitLetFloat</span></a></span></span><span> </span><span id="local-6989586621680958626"><span class="annot"><span class="annottext">OutBind
</span><a href="#local-6989586621680958626"><span class="hs-identifier hs-var">bind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span class="hs-identifier">all</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">not</span><span> </span><span class="hs-operator">.</span><span> </span><span class="hs-identifier">isJoinId</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">bindersOf</span><span> </span><span class="hs-identifier">bind</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-496"></span><span>                    </span><span class="annot"><span class="annottext">JoinFloats -&gt; FloatFlag -&gt; LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#LetFloats"><span class="hs-identifier hs-var">LetFloats</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OutBind -&gt; JoinFloats
forall a. a -&gt; OrdList a
</span><a href="GHC.Data.OrdList.html#unitOL"><span class="hs-identifier hs-var">unitOL</span></a></span><span> </span><span class="annot"><span class="annottext">OutBind
</span><a href="#local-6989586621680958626"><span class="hs-identifier hs-var">bind</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OutBind -&gt; FloatFlag
</span><a href="#local-6989586621680958621"><span class="hs-identifier hs-var">flag</span></a></span><span> </span><span class="annot"><span class="annottext">OutBind
</span><a href="#local-6989586621680958626"><span class="hs-identifier hs-var">bind</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-497"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-498"></span><span>    </span><span id="local-6989586621680958621"><span class="annot"><span class="annottext">flag :: OutBind -&gt; FloatFlag
</span><a href="#local-6989586621680958621"><span class="hs-identifier hs-var hs-var">flag</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-type">Rec</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span>                </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FloatFlag
</span><a href="GHC.Core.Opt.Simplify.Env.html#FltLifted"><span class="hs-identifier hs-var">FltLifted</span></a></span><span>
</span><span id="line-499"></span><span>    </span><span class="annot"><a href="#local-6989586621680958621"><span class="hs-identifier hs-var">flag</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-type">NonRec</span></a></span><span> </span><span id="local-6989586621680958614"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958614"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621680958613"><span class="annot"><span class="annottext">OutExpr
</span><a href="#local-6989586621680958613"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-500"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InBndr -&gt; Bool
</span><a href="GHC.Types.Id.html#isStrictId"><span class="hs-identifier hs-var">isStrictId</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958614"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FloatFlag
</span><a href="GHC.Core.Opt.Simplify.Env.html#FltLifted"><span class="hs-identifier hs-var">FltLifted</span></a></span><span>
</span><span id="line-501"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">OutExpr -&gt; Bool
</span><a href="GHC.Core.Utils.html#exprIsTickedString"><span class="hs-identifier hs-var">exprIsTickedString</span></a></span><span> </span><span class="annot"><span class="annottext">OutExpr
</span><a href="#local-6989586621680958613"><span class="hs-identifier hs-var">rhs</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FloatFlag
</span><a href="GHC.Core.Opt.Simplify.Env.html#FltLifted"><span class="hs-identifier hs-var">FltLifted</span></a></span><span>
</span><span id="line-502"></span><span>          </span><span class="hs-comment">-- String literals can be floated freely.</span><span>
</span><span id="line-503"></span><span>          </span><span class="hs-comment">-- See Note [Core top-level string literals] in GHC.Core.</span><span>
</span><span id="line-504"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">OutExpr -&gt; Bool
</span><a href="GHC.Core.Utils.html#exprOkForSpeculation"><span class="hs-identifier hs-var">exprOkForSpeculation</span></a></span><span> </span><span class="annot"><span class="annottext">OutExpr
</span><a href="#local-6989586621680958613"><span class="hs-identifier hs-var">rhs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FloatFlag
</span><a href="GHC.Core.Opt.Simplify.Env.html#FltOkSpec"><span class="hs-identifier hs-var">FltOkSpec</span></a></span><span>  </span><span class="hs-comment">-- Unlifted, and lifted but ok-for-spec (eg HNF)</span><span>
</span><span id="line-505"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">not</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">isUnliftedType</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">idType</span><span> </span><span class="hs-identifier">bndr</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">bndr</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-506"></span><span>                                   </span><span class="annot"><span class="annottext">FloatFlag
</span><a href="GHC.Core.Opt.Simplify.Env.html#FltCareful"><span class="hs-identifier hs-var">FltCareful</span></a></span><span>
</span><span id="line-507"></span><span>      </span><span class="hs-comment">-- Unlifted binders can only be let-bound if exprOkForSpeculation holds</span><span>
</span><span id="line-508"></span><span>
</span><span id="line-509"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#unitJoinFloat"><span class="hs-identifier hs-type">unitJoinFloat</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.html#OutBind"><span class="hs-identifier hs-type">OutBind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#JoinFloats"><span class="hs-identifier hs-type">JoinFloats</span></a></span><span>
</span><span id="line-510"></span><span id="unitJoinFloat"><span class="annot"><span class="annottext">unitJoinFloat :: OutBind -&gt; JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#unitJoinFloat"><span class="hs-identifier hs-var hs-var">unitJoinFloat</span></a></span></span><span> </span><span id="local-6989586621680958607"><span class="annot"><span class="annottext">OutBind
</span><a href="#local-6989586621680958607"><span class="hs-identifier hs-var">bind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span class="hs-identifier">all</span><span> </span><span class="hs-identifier">isJoinId</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">bindersOf</span><span> </span><span class="hs-identifier">bind</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-511"></span><span>                     </span><span class="annot"><span class="annottext">OutBind -&gt; JoinFloats
forall a. a -&gt; OrdList a
</span><a href="GHC.Data.OrdList.html#unitOL"><span class="hs-identifier hs-var">unitOL</span></a></span><span> </span><span class="annot"><span class="annottext">OutBind
</span><a href="#local-6989586621680958607"><span class="hs-identifier hs-var">bind</span></a></span><span>
</span><span id="line-512"></span><span>
</span><span id="line-513"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#mkFloatBind"><span class="hs-identifier hs-type">mkFloatBind</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#OutBind"><span class="hs-identifier hs-type">OutBind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-514"></span><span class="hs-comment">-- Make a singleton SimplFloats, and</span><span>
</span><span id="line-515"></span><span class="hs-comment">-- extend the incoming SimplEnv's in-scope set with its binders</span><span>
</span><span id="line-516"></span><span class="hs-comment">-- These binders may already be in the in-scope set,</span><span>
</span><span id="line-517"></span><span class="hs-comment">-- but may have by now been augmented with more IdInfo</span><span>
</span><span id="line-518"></span><span id="mkFloatBind"><span class="annot"><span class="annottext">mkFloatBind :: SimplEnv -&gt; OutBind -&gt; (SimplFloats, SimplEnv)
</span><a href="GHC.Core.Opt.Simplify.Env.html#mkFloatBind"><span class="hs-identifier hs-var hs-var">mkFloatBind</span></a></span></span><span> </span><span id="local-6989586621680958606"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958606"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680958605"><span class="annot"><span class="annottext">OutBind
</span><a href="#local-6989586621680958605"><span class="hs-identifier hs-var">bind</span></a></span></span><span>
</span><span id="line-519"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SimplFloats
</span><a href="#local-6989586621680958604"><span class="hs-identifier hs-var">floats</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958606"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">seInScope :: InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#seInScope"><span class="hs-identifier hs-var">seInScope</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958603"><span class="hs-identifier hs-var">in_scope'</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-520"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-521"></span><span>    </span><span id="local-6989586621680958604"><span class="annot"><span class="annottext">floats :: SimplFloats
</span><a href="#local-6989586621680958604"><span class="hs-identifier hs-var hs-var">floats</span></a></span></span><span>
</span><span id="line-522"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">OutBind -&gt; Bool
</span><a href="GHC.Core.Utils.html#isJoinBind"><span class="hs-identifier hs-var">isJoinBind</span></a></span><span> </span><span class="annot"><span class="annottext">OutBind
</span><a href="#local-6989586621680958605"><span class="hs-identifier hs-var">bind</span></a></span><span>
</span><span id="line-523"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplFloats :: LetFloats -&gt; JoinFloats -&gt; InScopeSet -&gt; SimplFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sfLetFloats :: LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfLetFloats"><span class="hs-identifier hs-var">sfLetFloats</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#emptyLetFloats"><span class="hs-identifier hs-var">emptyLetFloats</span></a></span><span>
</span><span id="line-524"></span><span>                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sfJoinFloats :: JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfJoinFloats"><span class="hs-identifier hs-var">sfJoinFloats</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OutBind -&gt; JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#unitJoinFloat"><span class="hs-identifier hs-var">unitJoinFloat</span></a></span><span> </span><span class="annot"><span class="annottext">OutBind
</span><a href="#local-6989586621680958605"><span class="hs-identifier hs-var">bind</span></a></span><span>
</span><span id="line-525"></span><span>                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sfInScope :: InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfInScope"><span class="hs-identifier hs-var">sfInScope</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958603"><span class="hs-identifier hs-var">in_scope'</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-526"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-527"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplFloats :: LetFloats -&gt; JoinFloats -&gt; InScopeSet -&gt; SimplFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sfLetFloats :: LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfLetFloats"><span class="hs-identifier hs-var">sfLetFloats</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OutBind -&gt; LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#unitLetFloat"><span class="hs-identifier hs-var">unitLetFloat</span></a></span><span> </span><span class="annot"><span class="annottext">OutBind
</span><a href="#local-6989586621680958605"><span class="hs-identifier hs-var">bind</span></a></span><span>
</span><span id="line-528"></span><span>                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sfJoinFloats :: JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfJoinFloats"><span class="hs-identifier hs-var">sfJoinFloats</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#emptyJoinFloats"><span class="hs-identifier hs-var">emptyJoinFloats</span></a></span><span>
</span><span id="line-529"></span><span>                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sfInScope :: InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfInScope"><span class="hs-identifier hs-var">sfInScope</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958603"><span class="hs-identifier hs-var">in_scope'</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-530"></span><span>
</span><span id="line-531"></span><span>    </span><span id="local-6989586621680958603"><span class="annot"><span class="annottext">in_scope' :: InScopeSet
</span><a href="#local-6989586621680958603"><span class="hs-identifier hs-var hs-var">in_scope'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplEnv -&gt; InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#seInScope"><span class="hs-identifier hs-var hs-var">seInScope</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958606"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; OutBind -&gt; InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#extendInScopeSetBind"><span class="hs-operator hs-var">`extendInScopeSetBind`</span></a></span><span> </span><span class="annot"><span class="annottext">OutBind
</span><a href="#local-6989586621680958605"><span class="hs-identifier hs-var">bind</span></a></span><span>
</span><span id="line-532"></span><span>
</span><span id="line-533"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#extendFloats"><span class="hs-identifier hs-type">extendFloats</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#OutBind"><span class="hs-identifier hs-type">OutBind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span>
</span><span id="line-534"></span><span class="hs-comment">-- Add this binding to the floats, and extend the in-scope env too</span><span>
</span><span id="line-535"></span><span id="extendFloats"><span class="annot"><span class="annottext">extendFloats :: SimplFloats -&gt; OutBind -&gt; SimplFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#extendFloats"><span class="hs-identifier hs-var hs-var">extendFloats</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sfLetFloats :: SimplFloats -&gt; LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfLetFloats"><span class="hs-identifier hs-var">sfLetFloats</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958600"><span class="annot"><span class="annottext">LetFloats
</span><a href="#local-6989586621680958600"><span class="hs-identifier hs-var">floats</span></a></span></span><span>
</span><span id="line-536"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sfJoinFloats :: SimplFloats -&gt; JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfJoinFloats"><span class="hs-identifier hs-var">sfJoinFloats</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958599"><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958599"><span class="hs-identifier hs-var">jfloats</span></a></span></span><span>
</span><span id="line-537"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sfInScope :: SimplFloats -&gt; InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfInScope"><span class="hs-identifier hs-var">sfInScope</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958598"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958598"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-538"></span><span>             </span><span id="local-6989586621680958597"><span class="annot"><span class="annottext">OutBind
</span><a href="#local-6989586621680958597"><span class="hs-identifier hs-var">bind</span></a></span></span><span>
</span><span id="line-539"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">OutBind -&gt; Bool
</span><a href="GHC.Core.Utils.html#isJoinBind"><span class="hs-identifier hs-var">isJoinBind</span></a></span><span> </span><span class="annot"><span class="annottext">OutBind
</span><a href="#local-6989586621680958597"><span class="hs-identifier hs-var">bind</span></a></span><span>
</span><span id="line-540"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplFloats :: LetFloats -&gt; JoinFloats -&gt; InScopeSet -&gt; SimplFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sfInScope :: InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfInScope"><span class="hs-identifier hs-var">sfInScope</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958596"><span class="hs-identifier hs-var">in_scope'</span></a></span><span>
</span><span id="line-541"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sfLetFloats :: LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfLetFloats"><span class="hs-identifier hs-var">sfLetFloats</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LetFloats
</span><a href="#local-6989586621680958600"><span class="hs-identifier hs-var">floats</span></a></span><span>
</span><span id="line-542"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sfJoinFloats :: JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfJoinFloats"><span class="hs-identifier hs-var">sfJoinFloats</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958595"><span class="hs-identifier hs-var">jfloats'</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-543"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-544"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplFloats :: LetFloats -&gt; JoinFloats -&gt; InScopeSet -&gt; SimplFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sfInScope :: InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfInScope"><span class="hs-identifier hs-var">sfInScope</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958596"><span class="hs-identifier hs-var">in_scope'</span></a></span><span>
</span><span id="line-545"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sfLetFloats :: LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfLetFloats"><span class="hs-identifier hs-var">sfLetFloats</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LetFloats
</span><a href="#local-6989586621680958594"><span class="hs-identifier hs-var">floats'</span></a></span><span>
</span><span id="line-546"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sfJoinFloats :: JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfJoinFloats"><span class="hs-identifier hs-var">sfJoinFloats</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958599"><span class="hs-identifier hs-var">jfloats</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-547"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-548"></span><span>    </span><span id="local-6989586621680958596"><span class="annot"><span class="annottext">in_scope' :: InScopeSet
</span><a href="#local-6989586621680958596"><span class="hs-identifier hs-var hs-var">in_scope'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958598"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; OutBind -&gt; InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#extendInScopeSetBind"><span class="hs-operator hs-var">`extendInScopeSetBind`</span></a></span><span> </span><span class="annot"><span class="annottext">OutBind
</span><a href="#local-6989586621680958597"><span class="hs-identifier hs-var">bind</span></a></span><span>
</span><span id="line-549"></span><span>    </span><span id="local-6989586621680958594"><span class="annot"><span class="annottext">floats' :: LetFloats
</span><a href="#local-6989586621680958594"><span class="hs-identifier hs-var hs-var">floats'</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LetFloats
</span><a href="#local-6989586621680958600"><span class="hs-identifier hs-var">floats</span></a></span><span>  </span><span class="annot"><span class="annottext">LetFloats -&gt; LetFloats -&gt; LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#addLetFlts"><span class="hs-operator hs-var">`addLetFlts`</span></a></span><span>  </span><span class="annot"><span class="annottext">OutBind -&gt; LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#unitLetFloat"><span class="hs-identifier hs-var">unitLetFloat</span></a></span><span> </span><span class="annot"><span class="annottext">OutBind
</span><a href="#local-6989586621680958597"><span class="hs-identifier hs-var">bind</span></a></span><span>
</span><span id="line-550"></span><span>    </span><span id="local-6989586621680958595"><span class="annot"><span class="annottext">jfloats' :: JoinFloats
</span><a href="#local-6989586621680958595"><span class="hs-identifier hs-var hs-var">jfloats'</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958599"><span class="hs-identifier hs-var">jfloats</span></a></span><span> </span><span class="annot"><span class="annottext">JoinFloats -&gt; JoinFloats -&gt; JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#addJoinFlts"><span class="hs-operator hs-var">`addJoinFlts`</span></a></span><span> </span><span class="annot"><span class="annottext">OutBind -&gt; JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#unitJoinFloat"><span class="hs-identifier hs-var">unitJoinFloat</span></a></span><span> </span><span class="annot"><span class="annottext">OutBind
</span><a href="#local-6989586621680958597"><span class="hs-identifier hs-var">bind</span></a></span><span>
</span><span id="line-551"></span><span>
</span><span id="line-552"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#addLetFloats"><span class="hs-identifier hs-type">addLetFloats</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#LetFloats"><span class="hs-identifier hs-type">LetFloats</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span>
</span><span id="line-553"></span><span class="hs-comment">-- Add the let-floats for env2 to env1;</span><span>
</span><span id="line-554"></span><span class="hs-comment">-- *plus* the in-scope set for env2, which is bigger</span><span>
</span><span id="line-555"></span><span class="hs-comment">-- than that for env1</span><span>
</span><span id="line-556"></span><span id="addLetFloats"><span class="annot"><span class="annottext">addLetFloats :: SimplFloats -&gt; LetFloats -&gt; SimplFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#addLetFloats"><span class="hs-identifier hs-var hs-var">addLetFloats</span></a></span></span><span> </span><span id="local-6989586621680958593"><span class="annot"><span class="annottext">SimplFloats
</span><a href="#local-6989586621680958593"><span class="hs-identifier hs-var">floats</span></a></span></span><span> </span><span id="local-6989586621680958592"><span class="annot"><span class="annottext">let_floats :: LetFloats
</span><a href="#local-6989586621680958592"><span class="hs-identifier hs-var">let_floats</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#LetFloats"><span class="hs-identifier hs-type">LetFloats</span></a></span><span> </span><span id="local-6989586621680958591"><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958591"><span class="hs-identifier hs-var">binds</span></a></span></span><span> </span><span class="annot"><span class="annottext">FloatFlag
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>
</span><span id="line-557"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplFloats
</span><a href="#local-6989586621680958593"><span class="hs-identifier hs-var">floats</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sfLetFloats :: LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfLetFloats"><span class="hs-identifier hs-var">sfLetFloats</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplFloats -&gt; LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfLetFloats"><span class="hs-identifier hs-var hs-var">sfLetFloats</span></a></span><span> </span><span class="annot"><span class="annottext">SimplFloats
</span><a href="#local-6989586621680958593"><span class="hs-identifier hs-var">floats</span></a></span><span> </span><span class="annot"><span class="annottext">LetFloats -&gt; LetFloats -&gt; LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#addLetFlts"><span class="hs-operator hs-var">`addLetFlts`</span></a></span><span> </span><span class="annot"><span class="annottext">LetFloats
</span><a href="#local-6989586621680958592"><span class="hs-identifier hs-var">let_floats</span></a></span><span>
</span><span id="line-558"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sfInScope :: InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfInScope"><span class="hs-identifier hs-var">sfInScope</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(InScopeSet -&gt; OutBind -&gt; InScopeSet)
-&gt; InScopeSet -&gt; JoinFloats -&gt; InScopeSet
forall b a. (b -&gt; a -&gt; b) -&gt; b -&gt; OrdList a -&gt; b
</span><a href="GHC.Data.OrdList.html#foldlOL"><span class="hs-identifier hs-var">foldlOL</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; OutBind -&gt; InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#extendInScopeSetBind"><span class="hs-identifier hs-var">extendInScopeSetBind</span></a></span><span>
</span><span id="line-559"></span><span>                                   </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SimplFloats -&gt; InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfInScope"><span class="hs-identifier hs-var hs-var">sfInScope</span></a></span><span> </span><span class="annot"><span class="annottext">SimplFloats
</span><a href="#local-6989586621680958593"><span class="hs-identifier hs-var">floats</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958591"><span class="hs-identifier hs-var">binds</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-560"></span><span>
</span><span id="line-561"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#addJoinFloats"><span class="hs-identifier hs-type">addJoinFloats</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#JoinFloats"><span class="hs-identifier hs-type">JoinFloats</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span>
</span><span id="line-562"></span><span id="addJoinFloats"><span class="annot"><span class="annottext">addJoinFloats :: SimplFloats -&gt; JoinFloats -&gt; SimplFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#addJoinFloats"><span class="hs-identifier hs-var hs-var">addJoinFloats</span></a></span></span><span> </span><span id="local-6989586621680958589"><span class="annot"><span class="annottext">SimplFloats
</span><a href="#local-6989586621680958589"><span class="hs-identifier hs-var">floats</span></a></span></span><span> </span><span id="local-6989586621680958588"><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958588"><span class="hs-identifier hs-var">join_floats</span></a></span></span><span>
</span><span id="line-563"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplFloats
</span><a href="#local-6989586621680958589"><span class="hs-identifier hs-var">floats</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sfJoinFloats :: JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfJoinFloats"><span class="hs-identifier hs-var">sfJoinFloats</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplFloats -&gt; JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfJoinFloats"><span class="hs-identifier hs-var hs-var">sfJoinFloats</span></a></span><span> </span><span class="annot"><span class="annottext">SimplFloats
</span><a href="#local-6989586621680958589"><span class="hs-identifier hs-var">floats</span></a></span><span> </span><span class="annot"><span class="annottext">JoinFloats -&gt; JoinFloats -&gt; JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#addJoinFlts"><span class="hs-operator hs-var">`addJoinFlts`</span></a></span><span> </span><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958588"><span class="hs-identifier hs-var">join_floats</span></a></span><span>
</span><span id="line-564"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sfInScope :: InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfInScope"><span class="hs-identifier hs-var">sfInScope</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(InScopeSet -&gt; OutBind -&gt; InScopeSet)
-&gt; InScopeSet -&gt; JoinFloats -&gt; InScopeSet
forall b a. (b -&gt; a -&gt; b) -&gt; b -&gt; OrdList a -&gt; b
</span><a href="GHC.Data.OrdList.html#foldlOL"><span class="hs-identifier hs-var">foldlOL</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; OutBind -&gt; InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#extendInScopeSetBind"><span class="hs-identifier hs-var">extendInScopeSetBind</span></a></span><span>
</span><span id="line-565"></span><span>                                    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SimplFloats -&gt; InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfInScope"><span class="hs-identifier hs-var hs-var">sfInScope</span></a></span><span> </span><span class="annot"><span class="annottext">SimplFloats
</span><a href="#local-6989586621680958589"><span class="hs-identifier hs-var">floats</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958588"><span class="hs-identifier hs-var">join_floats</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-566"></span><span>
</span><span id="line-567"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#extendInScopeSetBind"><span class="hs-identifier hs-type">extendInScopeSetBind</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span>
</span><span id="line-568"></span><span id="extendInScopeSetBind"><span class="annot"><span class="annottext">extendInScopeSetBind :: InScopeSet -&gt; OutBind -&gt; InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#extendInScopeSetBind"><span class="hs-identifier hs-var hs-var">extendInScopeSetBind</span></a></span></span><span> </span><span id="local-6989586621680958586"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958586"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680958585"><span class="annot"><span class="annottext">OutBind
</span><a href="#local-6989586621680958585"><span class="hs-identifier hs-var">bind</span></a></span></span><span>
</span><span id="line-569"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; [InBndr] -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#extendInScopeSetList"><span class="hs-identifier hs-var">extendInScopeSetList</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958586"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OutBind -&gt; [InBndr]
forall b. Bind b -&gt; [b]
</span><a href="GHC.Core.html#bindersOf"><span class="hs-identifier hs-var">bindersOf</span></a></span><span> </span><span class="annot"><span class="annottext">OutBind
</span><a href="#local-6989586621680958585"><span class="hs-identifier hs-var">bind</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-570"></span><span>
</span><span id="line-571"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#addFloats"><span class="hs-identifier hs-type">addFloats</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span>
</span><span id="line-572"></span><span class="hs-comment">-- Add both let-floats and join-floats for env2 to env1;</span><span>
</span><span id="line-573"></span><span class="hs-comment">-- *plus* the in-scope set for env2, which is bigger</span><span>
</span><span id="line-574"></span><span class="hs-comment">-- than that for env1</span><span>
</span><span id="line-575"></span><span id="addFloats"><span class="annot"><span class="annottext">addFloats :: SimplFloats -&gt; SimplFloats -&gt; SimplFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#addFloats"><span class="hs-identifier hs-var hs-var">addFloats</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sfLetFloats :: SimplFloats -&gt; LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfLetFloats"><span class="hs-identifier hs-var">sfLetFloats</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958584"><span class="annot"><span class="annottext">LetFloats
</span><a href="#local-6989586621680958584"><span class="hs-identifier hs-var">lf1</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sfJoinFloats :: SimplFloats -&gt; JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfJoinFloats"><span class="hs-identifier hs-var">sfJoinFloats</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958583"><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958583"><span class="hs-identifier hs-var">jf1</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-576"></span><span>          </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sfLetFloats :: SimplFloats -&gt; LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfLetFloats"><span class="hs-identifier hs-var">sfLetFloats</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958582"><span class="annot"><span class="annottext">LetFloats
</span><a href="#local-6989586621680958582"><span class="hs-identifier hs-var">lf2</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sfJoinFloats :: SimplFloats -&gt; JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfJoinFloats"><span class="hs-identifier hs-var">sfJoinFloats</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958581"><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958581"><span class="hs-identifier hs-var">jf2</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sfInScope :: SimplFloats -&gt; InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfInScope"><span class="hs-identifier hs-var">sfInScope</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958580"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958580"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-577"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplFloats :: LetFloats -&gt; JoinFloats -&gt; InScopeSet -&gt; SimplFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sfLetFloats :: LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfLetFloats"><span class="hs-identifier hs-var">sfLetFloats</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LetFloats
</span><a href="#local-6989586621680958584"><span class="hs-identifier hs-var">lf1</span></a></span><span> </span><span class="annot"><span class="annottext">LetFloats -&gt; LetFloats -&gt; LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#addLetFlts"><span class="hs-operator hs-var">`addLetFlts`</span></a></span><span> </span><span class="annot"><span class="annottext">LetFloats
</span><a href="#local-6989586621680958582"><span class="hs-identifier hs-var">lf2</span></a></span><span>
</span><span id="line-578"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sfJoinFloats :: JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfJoinFloats"><span class="hs-identifier hs-var">sfJoinFloats</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958583"><span class="hs-identifier hs-var">jf1</span></a></span><span> </span><span class="annot"><span class="annottext">JoinFloats -&gt; JoinFloats -&gt; JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#addJoinFlts"><span class="hs-operator hs-var">`addJoinFlts`</span></a></span><span> </span><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958581"><span class="hs-identifier hs-var">jf2</span></a></span><span>
</span><span id="line-579"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sfInScope :: InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfInScope"><span class="hs-identifier hs-var">sfInScope</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958580"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-580"></span><span>
</span><span id="line-581"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#addLetFlts"><span class="hs-identifier hs-type">addLetFlts</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#LetFloats"><span class="hs-identifier hs-type">LetFloats</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#LetFloats"><span class="hs-identifier hs-type">LetFloats</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#LetFloats"><span class="hs-identifier hs-type">LetFloats</span></a></span><span>
</span><span id="line-582"></span><span id="addLetFlts"><span class="annot"><span class="annottext">addLetFlts :: LetFloats -&gt; LetFloats -&gt; LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#addLetFlts"><span class="hs-identifier hs-var hs-var">addLetFlts</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#LetFloats"><span class="hs-identifier hs-type">LetFloats</span></a></span><span> </span><span id="local-6989586621680958579"><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958579"><span class="hs-identifier hs-var">bs1</span></a></span></span><span> </span><span id="local-6989586621680958578"><span class="annot"><span class="annottext">FloatFlag
</span><a href="#local-6989586621680958578"><span class="hs-identifier hs-var">l1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#LetFloats"><span class="hs-identifier hs-type">LetFloats</span></a></span><span> </span><span id="local-6989586621680958577"><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958577"><span class="hs-identifier hs-var">bs2</span></a></span></span><span> </span><span id="local-6989586621680958576"><span class="annot"><span class="annottext">FloatFlag
</span><a href="#local-6989586621680958576"><span class="hs-identifier hs-var">l2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-583"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinFloats -&gt; FloatFlag -&gt; LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#LetFloats"><span class="hs-identifier hs-var">LetFloats</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958579"><span class="hs-identifier hs-var">bs1</span></a></span><span> </span><span class="annot"><span class="annottext">JoinFloats -&gt; JoinFloats -&gt; JoinFloats
forall a. OrdList a -&gt; OrdList a -&gt; OrdList a
</span><a href="GHC.Data.OrdList.html#appOL"><span class="hs-operator hs-var">`appOL`</span></a></span><span> </span><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958577"><span class="hs-identifier hs-var">bs2</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FloatFlag
</span><a href="#local-6989586621680958578"><span class="hs-identifier hs-var">l1</span></a></span><span> </span><span class="annot"><span class="annottext">FloatFlag -&gt; FloatFlag -&gt; FloatFlag
</span><a href="GHC.Core.Opt.Simplify.Env.html#andFF"><span class="hs-operator hs-var">`andFF`</span></a></span><span> </span><span class="annot"><span class="annottext">FloatFlag
</span><a href="#local-6989586621680958576"><span class="hs-identifier hs-var">l2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-584"></span><span>
</span><span id="line-585"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#letFloatBinds"><span class="hs-identifier hs-type">letFloatBinds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#LetFloats"><span class="hs-identifier hs-type">LetFloats</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-586"></span><span id="letFloatBinds"><span class="annot"><span class="annottext">letFloatBinds :: LetFloats -&gt; [OutBind]
</span><a href="GHC.Core.Opt.Simplify.Env.html#letFloatBinds"><span class="hs-identifier hs-var hs-var">letFloatBinds</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#LetFloats"><span class="hs-identifier hs-type">LetFloats</span></a></span><span> </span><span id="local-6989586621680958574"><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958574"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="annot"><span class="annottext">FloatFlag
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinFloats -&gt; [OutBind]
forall a. OrdList a -&gt; [a]
</span><a href="GHC.Data.OrdList.html#fromOL"><span class="hs-identifier hs-var">fromOL</span></a></span><span> </span><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958574"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-587"></span><span>
</span><span id="line-588"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#addJoinFlts"><span class="hs-identifier hs-type">addJoinFlts</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#JoinFloats"><span class="hs-identifier hs-type">JoinFloats</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#JoinFloats"><span class="hs-identifier hs-type">JoinFloats</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#JoinFloats"><span class="hs-identifier hs-type">JoinFloats</span></a></span><span>
</span><span id="line-589"></span><span id="addJoinFlts"><span class="annot"><span class="annottext">addJoinFlts :: JoinFloats -&gt; JoinFloats -&gt; JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#addJoinFlts"><span class="hs-identifier hs-var hs-var">addJoinFlts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinFloats -&gt; JoinFloats -&gt; JoinFloats
forall a. OrdList a -&gt; OrdList a -&gt; OrdList a
</span><a href="GHC.Data.OrdList.html#appOL"><span class="hs-identifier hs-var">appOL</span></a></span><span>
</span><span id="line-590"></span><span>
</span><span id="line-591"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#mkRecFloats"><span class="hs-identifier hs-type">mkRecFloats</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span>
</span><span id="line-592"></span><span class="hs-comment">-- Flattens the floats from env2 into a single Rec group,</span><span>
</span><span id="line-593"></span><span class="hs-comment">-- They must either all be lifted LetFloats or all JoinFloats</span><span>
</span><span id="line-594"></span><span id="mkRecFloats"><span class="annot"><span class="annottext">mkRecFloats :: SimplFloats -&gt; SimplFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#mkRecFloats"><span class="hs-identifier hs-var hs-var">mkRecFloats</span></a></span></span><span> </span><span id="local-6989586621680958573"><span class="annot"><span class="annottext">floats :: SimplFloats
</span><a href="#local-6989586621680958573"><span class="hs-identifier hs-var">floats</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sfLetFloats :: SimplFloats -&gt; LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfLetFloats"><span class="hs-identifier hs-var">sfLetFloats</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#LetFloats"><span class="hs-identifier hs-type">LetFloats</span></a></span><span> </span><span id="local-6989586621680958572"><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958572"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span id="local-6989586621680958571"><span class="annot"><span class="annottext">FloatFlag
</span><a href="#local-6989586621680958571"><span class="hs-identifier hs-var">ff</span></a></span></span><span>
</span><span id="line-595"></span><span>                                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sfJoinFloats :: SimplFloats -&gt; JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfJoinFloats"><span class="hs-identifier hs-var">sfJoinFloats</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958570"><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958570"><span class="hs-identifier hs-var">jbs</span></a></span></span><span>
</span><span id="line-596"></span><span>                                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sfInScope :: SimplFloats -&gt; InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfInScope"><span class="hs-identifier hs-var">sfInScope</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958569"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958569"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-597"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="hs-identifier">ff</span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-identifier">FltLifted</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">True</span><span class="hs-special">;</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">False</span><span> </span><span class="hs-special">}</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fromOL</span><span> </span><span class="hs-identifier">bs</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-598"></span><span>    </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isNilOL</span><span> </span><span class="hs-identifier">bs</span><span> </span><span class="hs-operator">||</span><span> </span><span class="hs-identifier">isNilOL</span><span> </span><span class="hs-identifier">jbs</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">floats</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-599"></span><span>    </span><span class="annot"><span class="annottext">SimplFloats :: LetFloats -&gt; JoinFloats -&gt; InScopeSet -&gt; SimplFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sfLetFloats :: LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfLetFloats"><span class="hs-identifier hs-var">sfLetFloats</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LetFloats
</span><a href="#local-6989586621680958568"><span class="hs-identifier hs-var">floats'</span></a></span><span>
</span><span id="line-600"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sfJoinFloats :: JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfJoinFloats"><span class="hs-identifier hs-var">sfJoinFloats</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958567"><span class="hs-identifier hs-var">jfloats'</span></a></span><span>
</span><span id="line-601"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sfInScope :: InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfInScope"><span class="hs-identifier hs-var">sfInScope</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958569"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-602"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-603"></span><span>    </span><span id="local-6989586621680958568"><span class="annot"><span class="annottext">floats' :: LetFloats
</span><a href="#local-6989586621680958568"><span class="hs-identifier hs-var hs-var">floats'</span></a></span></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">JoinFloats -&gt; Bool
forall a. OrdList a -&gt; Bool
</span><a href="GHC.Data.OrdList.html#isNilOL"><span class="hs-identifier hs-var">isNilOL</span></a></span><span> </span><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958572"><span class="hs-identifier hs-var">bs</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#emptyLetFloats"><span class="hs-identifier hs-var">emptyLetFloats</span></a></span><span>
</span><span id="line-604"></span><span>             </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OutBind -&gt; LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#unitLetFloat"><span class="hs-identifier hs-var">unitLetFloat</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(InBndr, OutExpr)] -&gt; OutBind
forall b. [(b, Expr b)] -&gt; Bind b
</span><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-var">Rec</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[OutBind] -&gt; [(InBndr, OutExpr)]
forall b. [Bind b] -&gt; [(b, Expr b)]
</span><a href="GHC.Core.html#flattenBinds"><span class="hs-identifier hs-var">flattenBinds</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinFloats -&gt; [OutBind]
forall a. OrdList a -&gt; [a]
</span><a href="GHC.Data.OrdList.html#fromOL"><span class="hs-identifier hs-var">fromOL</span></a></span><span> </span><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958572"><span class="hs-identifier hs-var">bs</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-605"></span><span>    </span><span id="local-6989586621680958567"><span class="annot"><span class="annottext">jfloats' :: JoinFloats
</span><a href="#local-6989586621680958567"><span class="hs-identifier hs-var hs-var">jfloats'</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">JoinFloats -&gt; Bool
forall a. OrdList a -&gt; Bool
</span><a href="GHC.Data.OrdList.html#isNilOL"><span class="hs-identifier hs-var">isNilOL</span></a></span><span> </span><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958570"><span class="hs-identifier hs-var">jbs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#emptyJoinFloats"><span class="hs-identifier hs-var">emptyJoinFloats</span></a></span><span>
</span><span id="line-606"></span><span>             </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OutBind -&gt; JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#unitJoinFloat"><span class="hs-identifier hs-var">unitJoinFloat</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(InBndr, OutExpr)] -&gt; OutBind
forall b. [(b, Expr b)] -&gt; Bind b
</span><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-var">Rec</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[OutBind] -&gt; [(InBndr, OutExpr)]
forall b. [Bind b] -&gt; [(b, Expr b)]
</span><a href="GHC.Core.html#flattenBinds"><span class="hs-identifier hs-var">flattenBinds</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinFloats -&gt; [OutBind]
forall a. OrdList a -&gt; [a]
</span><a href="GHC.Data.OrdList.html#fromOL"><span class="hs-identifier hs-var">fromOL</span></a></span><span> </span><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958570"><span class="hs-identifier hs-var">jbs</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-607"></span><span>
</span><span id="line-608"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#wrapFloats"><span class="hs-identifier hs-type">wrapFloats</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span>
</span><span id="line-609"></span><span class="hs-comment">-- Wrap the floats around the expression; they should all</span><span>
</span><span id="line-610"></span><span class="hs-comment">-- satisfy the let/app invariant, so mkLets should do the job just fine</span><span>
</span><span id="line-611"></span><span id="wrapFloats"><span class="annot"><span class="annottext">wrapFloats :: SimplFloats -&gt; OutExpr -&gt; OutExpr
</span><a href="GHC.Core.Opt.Simplify.Env.html#wrapFloats"><span class="hs-identifier hs-var hs-var">wrapFloats</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sfLetFloats :: SimplFloats -&gt; LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfLetFloats"><span class="hs-identifier hs-var">sfLetFloats</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#LetFloats"><span class="hs-identifier hs-type">LetFloats</span></a></span><span> </span><span id="local-6989586621680958565"><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958565"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="annot"><span class="annottext">FloatFlag
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-612"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sfJoinFloats :: SimplFloats -&gt; JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfJoinFloats"><span class="hs-identifier hs-var">sfJoinFloats</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958564"><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958564"><span class="hs-identifier hs-var">jbs</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680958563"><span class="annot"><span class="annottext">OutExpr
</span><a href="#local-6989586621680958563"><span class="hs-identifier hs-var">body</span></a></span></span><span>
</span><span id="line-613"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(OutBind -&gt; OutExpr -&gt; OutExpr) -&gt; OutExpr -&gt; JoinFloats -&gt; OutExpr
forall a b. (a -&gt; b -&gt; b) -&gt; b -&gt; OrdList a -&gt; b
</span><a href="GHC.Data.OrdList.html#foldrOL"><span class="hs-identifier hs-var">foldrOL</span></a></span><span> </span><span class="annot"><span class="annottext">OutBind -&gt; OutExpr -&gt; OutExpr
forall b. Bind b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Let"><span class="hs-identifier hs-var">Let</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinFloats -&gt; OutExpr -&gt; OutExpr
</span><a href="GHC.Core.Opt.Simplify.Env.html#wrapJoinFloats"><span class="hs-identifier hs-var">wrapJoinFloats</span></a></span><span> </span><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958564"><span class="hs-identifier hs-var">jbs</span></a></span><span> </span><span class="annot"><span class="annottext">OutExpr
</span><a href="#local-6989586621680958563"><span class="hs-identifier hs-var">body</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958565"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-614"></span><span>     </span><span class="hs-comment">-- Note: Always safe to put the joins on the inside</span><span>
</span><span id="line-615"></span><span>     </span><span class="hs-comment">-- since the values can't refer to them</span><span>
</span><span id="line-616"></span><span>
</span><span id="line-617"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#wrapJoinFloatsX"><span class="hs-identifier hs-type">wrapJoinFloatsX</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-618"></span><span class="hs-comment">-- Wrap the sfJoinFloats of the env around the expression,</span><span>
</span><span id="line-619"></span><span class="hs-comment">-- and take them out of the SimplEnv</span><span>
</span><span id="line-620"></span><span id="wrapJoinFloatsX"><span class="annot"><span class="annottext">wrapJoinFloatsX :: SimplFloats -&gt; OutExpr -&gt; (SimplFloats, OutExpr)
</span><a href="GHC.Core.Opt.Simplify.Env.html#wrapJoinFloatsX"><span class="hs-identifier hs-var hs-var">wrapJoinFloatsX</span></a></span></span><span> </span><span id="local-6989586621680958560"><span class="annot"><span class="annottext">SimplFloats
</span><a href="#local-6989586621680958560"><span class="hs-identifier hs-var">floats</span></a></span></span><span> </span><span id="local-6989586621680958559"><span class="annot"><span class="annottext">OutExpr
</span><a href="#local-6989586621680958559"><span class="hs-identifier hs-var">body</span></a></span></span><span>
</span><span id="line-621"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">SimplFloats
</span><a href="#local-6989586621680958560"><span class="hs-identifier hs-var">floats</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sfJoinFloats :: JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfJoinFloats"><span class="hs-identifier hs-var">sfJoinFloats</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#emptyJoinFloats"><span class="hs-identifier hs-var">emptyJoinFloats</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-622"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">JoinFloats -&gt; OutExpr -&gt; OutExpr
</span><a href="GHC.Core.Opt.Simplify.Env.html#wrapJoinFloats"><span class="hs-identifier hs-var">wrapJoinFloats</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SimplFloats -&gt; JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfJoinFloats"><span class="hs-identifier hs-var hs-var">sfJoinFloats</span></a></span><span> </span><span class="annot"><span class="annottext">SimplFloats
</span><a href="#local-6989586621680958560"><span class="hs-identifier hs-var">floats</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">OutExpr
</span><a href="#local-6989586621680958559"><span class="hs-identifier hs-var">body</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-623"></span><span>
</span><span id="line-624"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#wrapJoinFloats"><span class="hs-identifier hs-type">wrapJoinFloats</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#JoinFloats"><span class="hs-identifier hs-type">JoinFloats</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span>
</span><span id="line-625"></span><span class="hs-comment">-- Wrap the sfJoinFloats of the env around the expression,</span><span>
</span><span id="line-626"></span><span class="hs-comment">-- and take them out of the SimplEnv</span><span>
</span><span id="line-627"></span><span id="wrapJoinFloats"><span class="annot"><span class="annottext">wrapJoinFloats :: JoinFloats -&gt; OutExpr -&gt; OutExpr
</span><a href="GHC.Core.Opt.Simplify.Env.html#wrapJoinFloats"><span class="hs-identifier hs-var hs-var">wrapJoinFloats</span></a></span></span><span> </span><span id="local-6989586621680958558"><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958558"><span class="hs-identifier hs-var">join_floats</span></a></span></span><span> </span><span id="local-6989586621680958557"><span class="annot"><span class="annottext">OutExpr
</span><a href="#local-6989586621680958557"><span class="hs-identifier hs-var">body</span></a></span></span><span>
</span><span id="line-628"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(OutBind -&gt; OutExpr -&gt; OutExpr) -&gt; OutExpr -&gt; JoinFloats -&gt; OutExpr
forall a b. (a -&gt; b -&gt; b) -&gt; b -&gt; OrdList a -&gt; b
</span><a href="GHC.Data.OrdList.html#foldrOL"><span class="hs-identifier hs-var">foldrOL</span></a></span><span> </span><span class="annot"><span class="annottext">OutBind -&gt; OutExpr -&gt; OutExpr
forall b. Bind b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Let"><span class="hs-identifier hs-var">Let</span></a></span><span> </span><span class="annot"><span class="annottext">OutExpr
</span><a href="#local-6989586621680958557"><span class="hs-identifier hs-var">body</span></a></span><span> </span><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958558"><span class="hs-identifier hs-var">join_floats</span></a></span><span>
</span><span id="line-629"></span><span>
</span><span id="line-630"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#getTopFloatBinds"><span class="hs-identifier hs-type">getTopFloatBinds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-631"></span><span id="getTopFloatBinds"><span class="annot"><span class="annottext">getTopFloatBinds :: SimplFloats -&gt; [OutBind]
</span><a href="GHC.Core.Opt.Simplify.Env.html#getTopFloatBinds"><span class="hs-identifier hs-var hs-var">getTopFloatBinds</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplFloats"><span class="hs-identifier hs-type">SimplFloats</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sfLetFloats :: SimplFloats -&gt; LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfLetFloats"><span class="hs-identifier hs-var">sfLetFloats</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958556"><span class="annot"><span class="annottext">LetFloats
</span><a href="#local-6989586621680958556"><span class="hs-identifier hs-var">lbs</span></a></span></span><span>
</span><span id="line-632"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sfJoinFloats :: SimplFloats -&gt; JoinFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#sfJoinFloats"><span class="hs-identifier hs-var">sfJoinFloats</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958555"><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958555"><span class="hs-identifier hs-var">jbs</span></a></span></span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-633"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isNilOL</span><span> </span><span class="hs-identifier">jbs</span><span> </span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- Can't be any top-level join bindings</span><span>
</span><span id="line-634"></span><span>    </span><span class="annot"><span class="annottext">LetFloats -&gt; [OutBind]
</span><a href="GHC.Core.Opt.Simplify.Env.html#letFloatBinds"><span class="hs-identifier hs-var">letFloatBinds</span></a></span><span> </span><span class="annot"><span class="annottext">LetFloats
</span><a href="#local-6989586621680958556"><span class="hs-identifier hs-var">lbs</span></a></span><span>
</span><span id="line-635"></span><span>
</span><span id="line-636"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#mapLetFloats"><span class="hs-identifier hs-type">mapLetFloats</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#LetFloats"><span class="hs-identifier hs-type">LetFloats</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#LetFloats"><span class="hs-identifier hs-type">LetFloats</span></a></span><span>
</span><span id="line-637"></span><span id="mapLetFloats"><span class="annot"><span class="annottext">mapLetFloats :: LetFloats -&gt; ((InBndr, OutExpr) -&gt; (InBndr, OutExpr)) -&gt; LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#mapLetFloats"><span class="hs-identifier hs-var hs-var">mapLetFloats</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#LetFloats"><span class="hs-identifier hs-type">LetFloats</span></a></span><span> </span><span id="local-6989586621680958553"><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958553"><span class="hs-identifier hs-var">fs</span></a></span></span><span> </span><span id="local-6989586621680958552"><span class="annot"><span class="annottext">FloatFlag
</span><a href="#local-6989586621680958552"><span class="hs-identifier hs-var">ff</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680958551"><span class="annot"><span class="annottext">(InBndr, OutExpr) -&gt; (InBndr, OutExpr)
</span><a href="#local-6989586621680958551"><span class="hs-identifier hs-var">fun</span></a></span></span><span>
</span><span id="line-638"></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinFloats -&gt; FloatFlag -&gt; LetFloats
</span><a href="GHC.Core.Opt.Simplify.Env.html#LetFloats"><span class="hs-identifier hs-var">LetFloats</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(OutBind -&gt; OutBind) -&gt; JoinFloats -&gt; JoinFloats
forall a b. (a -&gt; b) -&gt; OrdList a -&gt; OrdList b
</span><a href="GHC.Data.OrdList.html#mapOL"><span class="hs-identifier hs-var">mapOL</span></a></span><span> </span><span class="annot"><span class="annottext">OutBind -&gt; OutBind
</span><a href="#local-6989586621680958549"><span class="hs-identifier hs-var">app</span></a></span><span> </span><span class="annot"><span class="annottext">JoinFloats
</span><a href="#local-6989586621680958553"><span class="hs-identifier hs-var">fs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">FloatFlag
</span><a href="#local-6989586621680958552"><span class="hs-identifier hs-var">ff</span></a></span><span>
</span><span id="line-639"></span><span>   </span><span class="hs-keyword">where</span><span>
</span><span id="line-640"></span><span>    </span><span id="local-6989586621680958549"><span class="annot"><span class="annottext">app :: OutBind -&gt; OutBind
</span><a href="#local-6989586621680958549"><span class="hs-identifier hs-var hs-var">app</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-type">NonRec</span></a></span><span> </span><span id="local-6989586621680958548"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958548"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621680958547"><span class="annot"><span class="annottext">OutExpr
</span><a href="#local-6989586621680958547"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">(InBndr, OutExpr) -&gt; (InBndr, OutExpr)
</span><a href="#local-6989586621680958551"><span class="hs-identifier hs-var">fun</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958548"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">OutExpr
</span><a href="#local-6989586621680958547"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680958546"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958546"><span class="hs-identifier hs-var">b'</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680958545"><span class="annot"><span class="annottext">OutExpr
</span><a href="#local-6989586621680958545"><span class="hs-identifier hs-var">e'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">InBndr -&gt; OutExpr -&gt; OutBind
forall b. b -&gt; Expr b -&gt; Bind b
</span><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-var">NonRec</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958546"><span class="hs-identifier hs-var">b'</span></a></span><span> </span><span class="annot"><span class="annottext">OutExpr
</span><a href="#local-6989586621680958545"><span class="hs-identifier hs-var">e'</span></a></span><span>
</span><span id="line-641"></span><span>    </span><span class="annot"><a href="#local-6989586621680958549"><span class="hs-identifier hs-var">app</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-type">Rec</span></a></span><span> </span><span id="local-6989586621680958544"><span class="annot"><span class="annottext">[(InBndr, OutExpr)]
</span><a href="#local-6989586621680958544"><span class="hs-identifier hs-var">bs</span></a></span></span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(InBndr, OutExpr)] -&gt; OutBind
forall b. [(b, Expr b)] -&gt; Bind b
</span><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-var">Rec</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((InBndr, OutExpr) -&gt; (InBndr, OutExpr))
-&gt; [(InBndr, OutExpr)] -&gt; [(InBndr, OutExpr)]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(InBndr, OutExpr) -&gt; (InBndr, OutExpr)
</span><a href="#local-6989586621680958551"><span class="hs-identifier hs-var">fun</span></a></span><span> </span><span class="annot"><span class="annottext">[(InBndr, OutExpr)]
</span><a href="#local-6989586621680958544"><span class="hs-identifier hs-var">bs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-642"></span><span>
</span><span id="line-643"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
                Substitution of Vars
*                                                                      *
************************************************************************

Note [Global Ids in the substitution]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We look up even a global (eg imported) Id in the substitution. Consider
   case X.g_34 of b { (a,b) -&gt;  ... case X.g_34 of { (p,q) -&gt; ...} ... }
The binder-swap in the occurrence analyser will add a binding
for a LocalId version of g (with the same unique though):
   case X.g_34 of b { (a,b) -&gt;  let g_34 = b in
                                ... case X.g_34 of { (p,q) -&gt; ...} ... }
So we want to look up the inner X.g_34 in the substitution, where we'll
find that it has been substituted by b.  (Or conceivably cloned.)
-}</span><span>
</span><span id="line-661"></span><span>
</span><span id="line-662"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#substId"><span class="hs-identifier hs-type">substId</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#InId"><span class="hs-identifier hs-type">InId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplSR"><span class="hs-identifier hs-type">SimplSR</span></a></span><span>
</span><span id="line-663"></span><span class="hs-comment">-- Returns DoneEx only on a non-Var expression</span><span>
</span><span id="line-664"></span><span id="substId"><span class="annot"><span class="annottext">substId :: SimplEnv -&gt; InBndr -&gt; SimplSR
</span><a href="GHC.Core.Opt.Simplify.Env.html#substId"><span class="hs-identifier hs-var hs-var">substId</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">seInScope :: SimplEnv -&gt; InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#seInScope"><span class="hs-identifier hs-var">seInScope</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958542"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958542"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">seIdSubst :: SimplEnv -&gt; SimplIdSubst
</span><a href="GHC.Core.Opt.Simplify.Env.html#seIdSubst"><span class="hs-identifier hs-var">seIdSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958541"><span class="annot"><span class="annottext">SimplIdSubst
</span><a href="#local-6989586621680958541"><span class="hs-identifier hs-var">ids</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680958540"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958540"><span class="hs-identifier hs-var">v</span></a></span></span><span>
</span><span id="line-665"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">SimplIdSubst -&gt; InBndr -&gt; Maybe SimplSR
forall a. VarEnv a -&gt; InBndr -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">SimplIdSubst
</span><a href="#local-6989586621680958541"><span class="hs-identifier hs-var">ids</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958540"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-keyword">of</span><span>  </span><span class="hs-comment">-- Note [Global Ids in the substitution]</span><span>
</span><span id="line-666"></span><span>        </span><span class="annot"><span class="annottext">Maybe SimplSR
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">InBndr -&gt; SimplSR
</span><a href="GHC.Core.Opt.Simplify.Env.html#DoneId"><span class="hs-identifier hs-var">DoneId</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; InBndr -&gt; InBndr
</span><a href="GHC.Core.Opt.Simplify.Env.html#refineFromInScope"><span class="hs-identifier hs-var">refineFromInScope</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958542"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958540"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-667"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#DoneId"><span class="hs-identifier hs-type">DoneId</span></a></span><span> </span><span id="local-6989586621680958538"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958538"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">)</span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">InBndr -&gt; SimplSR
</span><a href="GHC.Core.Opt.Simplify.Env.html#DoneId"><span class="hs-identifier hs-var">DoneId</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; InBndr -&gt; InBndr
</span><a href="GHC.Core.Opt.Simplify.Env.html#refineFromInScope"><span class="hs-identifier hs-var">refineFromInScope</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958542"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958538"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-668"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680958537"><span class="annot"><span class="annottext">SimplSR
</span><a href="#local-6989586621680958537"><span class="hs-identifier hs-var">res</span></a></span></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">SimplSR
</span><a href="#local-6989586621680958537"><span class="hs-identifier hs-var">res</span></a></span><span>    </span><span class="hs-comment">-- DoneEx non-var, or ContEx</span><span>
</span><span id="line-669"></span><span>
</span><span id="line-670"></span><span>        </span><span class="hs-comment">-- Get the most up-to-date thing from the in-scope set</span><span>
</span><span id="line-671"></span><span>        </span><span class="hs-comment">-- Even though it isn't in the substitution, it may be in</span><span>
</span><span id="line-672"></span><span>        </span><span class="hs-comment">-- the in-scope set with better IdInfo.</span><span>
</span><span id="line-673"></span><span>        </span><span class="hs-comment">--</span><span>
</span><span id="line-674"></span><span>        </span><span class="hs-comment">-- See also Note [In-scope set as a substitution] in GHC.Core.Opt.Simplify.</span><span>
</span><span id="line-675"></span><span>
</span><span id="line-676"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#refineFromInScope"><span class="hs-identifier hs-type">refineFromInScope</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span>
</span><span id="line-677"></span><span id="refineFromInScope"><span class="annot"><span class="annottext">refineFromInScope :: InScopeSet -&gt; InBndr -&gt; InBndr
</span><a href="GHC.Core.Opt.Simplify.Env.html#refineFromInScope"><span class="hs-identifier hs-var hs-var">refineFromInScope</span></a></span></span><span> </span><span id="local-6989586621680958535"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958535"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680958534"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958534"><span class="hs-identifier hs-var">v</span></a></span></span><span>
</span><span id="line-678"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">InBndr -&gt; Bool
</span><a href="GHC.Types.Var.html#isLocalId"><span class="hs-identifier hs-var">isLocalId</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958534"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; InBndr -&gt; Maybe InBndr
</span><a href="GHC.Types.Var.Env.html#lookupInScope"><span class="hs-identifier hs-var">lookupInScope</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958535"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958534"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-679"></span><span>                  </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680958531"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958531"><span class="hs-identifier hs-var">v'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958531"><span class="hs-identifier hs-var">v'</span></a></span><span>
</span><span id="line-680"></span><span>                  </span><span class="annot"><span class="annottext">Maybe InBndr
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">WARN</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">True</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">v</span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-identifier">v</span><span>  </span><span class="hs-comment">-- This is an error!</span><span>
</span><span id="line-681"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958534"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-682"></span><span>
</span><span id="line-683"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#lookupRecBndr"><span class="hs-identifier hs-type">lookupRecBndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#InId"><span class="hs-identifier hs-type">InId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span>
</span><span id="line-684"></span><span class="hs-comment">-- Look up an Id which has been put into the envt by simplRecBndrs,</span><span>
</span><span id="line-685"></span><span class="hs-comment">-- but where we have not yet done its RHS</span><span>
</span><span id="line-686"></span><span id="lookupRecBndr"><span class="annot"><span class="annottext">lookupRecBndr :: SimplEnv -&gt; InBndr -&gt; InBndr
</span><a href="GHC.Core.Opt.Simplify.Env.html#lookupRecBndr"><span class="hs-identifier hs-var hs-var">lookupRecBndr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">seInScope :: SimplEnv -&gt; InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#seInScope"><span class="hs-identifier hs-var">seInScope</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958529"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958529"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">seIdSubst :: SimplEnv -&gt; SimplIdSubst
</span><a href="GHC.Core.Opt.Simplify.Env.html#seIdSubst"><span class="hs-identifier hs-var">seIdSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958528"><span class="annot"><span class="annottext">SimplIdSubst
</span><a href="#local-6989586621680958528"><span class="hs-identifier hs-var">ids</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680958527"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958527"><span class="hs-identifier hs-var">v</span></a></span></span><span>
</span><span id="line-687"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">SimplIdSubst -&gt; InBndr -&gt; Maybe SimplSR
forall a. VarEnv a -&gt; InBndr -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">SimplIdSubst
</span><a href="#local-6989586621680958528"><span class="hs-identifier hs-var">ids</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958527"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-688"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#DoneId"><span class="hs-identifier hs-type">DoneId</span></a></span><span> </span><span id="local-6989586621680958526"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958526"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958526"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-689"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="annot"><span class="annottext">SimplSR
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; InBndr
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;lookupRecBndr&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InBndr -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958527"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-690"></span><span>        </span><span class="annot"><span class="annottext">Maybe SimplSR
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; InBndr -&gt; InBndr
</span><a href="GHC.Core.Opt.Simplify.Env.html#refineFromInScope"><span class="hs-identifier hs-var">refineFromInScope</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958529"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958527"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-691"></span><span>
</span><span id="line-692"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
\section{Substituting an Id binder}
*                                                                      *
************************************************************************


These functions are in the monad only so that they can be made strict via seq.

Note [Return type for join points]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider

   (join j :: Char -&gt; Int -&gt; Int) 77
   (     j x = \y. y + ord x    )
   (in case v of                )
   (     A -&gt; j 'x'             )
   (     B -&gt; j 'y'             )
   (     C -&gt; &lt;blah&gt;            )

The simplifier pushes the &quot;apply to 77&quot; continuation inwards to give

   join j :: Char -&gt; Int
        j x = (\y. y + ord x) 77
   in case v of
        A -&gt; j 'x'
        B -&gt; j 'y'
        C -&gt; &lt;blah&gt; 77

Notice that the &quot;apply to 77&quot; continuation went into the RHS of the
join point.  And that meant that the return type of the join point
changed!!

That's why we pass res_ty into simplNonRecJoinBndr, and substIdBndr
takes a (Just res_ty) argument so that it knows to do the type-changing
thing.

See also Note [Scaling join point arguments].
-}</span><span>
</span><span id="line-732"></span><span>
</span><span id="line-733"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#simplBinders"><span class="hs-identifier hs-type">simplBinders</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#InBndr"><span class="hs-identifier hs-type">InBndr</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Monad.html#SimplM"><span class="hs-identifier hs-type">SimplM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#OutBndr"><span class="hs-identifier hs-type">OutBndr</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-734"></span><span id="simplBinders"><span class="annot"><span class="annottext">simplBinders :: SimplEnv -&gt; [InBndr] -&gt; SimplM (SimplEnv, [InBndr])
</span><a href="GHC.Core.Opt.Simplify.Env.html#simplBinders"><span class="hs-identifier hs-var hs-var">simplBinders</span></a></span></span><span>  </span><span id="local-6989586621680958523"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958523"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680958522"><span class="annot"><span class="annottext">[InBndr]
</span><a href="#local-6989586621680958522"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(SimplEnv -&gt; InBndr -&gt; SimplM (SimplEnv, InBndr))
-&gt; SimplEnv -&gt; [InBndr] -&gt; SimplM (SimplEnv, [InBndr])
forall (m :: * -&gt; *) acc x y.
Monad m =&gt;
(acc -&gt; x -&gt; m (acc, y)) -&gt; acc -&gt; [x] -&gt; m (acc, [y])
</span><a href="GHC.Utils.Monad.html#mapAccumLM"><span class="hs-identifier hs-var">mapAccumLM</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv -&gt; InBndr -&gt; SimplM (SimplEnv, InBndr)
</span><a href="GHC.Core.Opt.Simplify.Env.html#simplBinder"><span class="hs-identifier hs-var">simplBinder</span></a></span><span>  </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958523"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[InBndr]
</span><a href="#local-6989586621680958522"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-735"></span><span>
</span><span id="line-736"></span><span class="hs-comment">-------------</span><span>
</span><span id="line-737"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#simplBinder"><span class="hs-identifier hs-type">simplBinder</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#InBndr"><span class="hs-identifier hs-type">InBndr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Monad.html#SimplM"><span class="hs-identifier hs-type">SimplM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#OutBndr"><span class="hs-identifier hs-type">OutBndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-738"></span><span class="hs-comment">-- Used for lambda and case-bound variables</span><span>
</span><span id="line-739"></span><span class="hs-comment">-- Clone Id if necessary, substitute type</span><span>
</span><span id="line-740"></span><span class="hs-comment">-- Return with IdInfo already substituted, but (fragile) occurrence info zapped</span><span>
</span><span id="line-741"></span><span class="hs-comment">-- The substitution is extended only if the variable is cloned, because</span><span>
</span><span id="line-742"></span><span class="hs-comment">-- we *don't* need to use it to track occurrence info.</span><span>
</span><span id="line-743"></span><span id="simplBinder"><span class="annot"><span class="annottext">simplBinder :: SimplEnv -&gt; InBndr -&gt; SimplM (SimplEnv, InBndr)
</span><a href="GHC.Core.Opt.Simplify.Env.html#simplBinder"><span class="hs-identifier hs-var hs-var">simplBinder</span></a></span></span><span> </span><span id="local-6989586621680958520"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958520"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680958519"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958519"><span class="hs-identifier hs-var">bndr</span></a></span></span><span>
</span><span id="line-744"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">InBndr -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958519"><span class="hs-identifier hs-var">bndr</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680958518"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958518"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680958517"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958517"><span class="hs-identifier hs-var">tv</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplEnv -&gt; InBndr -&gt; (SimplEnv, InBndr)
</span><a href="GHC.Core.Opt.Simplify.Env.html#substTyVarBndr"><span class="hs-identifier hs-var">substTyVarBndr</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958520"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958519"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-745"></span><span>                        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">InBndr -&gt; ()
</span><a href="GHC.Core.Opt.Simplify.Env.html#seqTyVar"><span class="hs-identifier hs-var">seqTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958517"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">() -&gt; SimplM (SimplEnv, InBndr) -&gt; SimplM (SimplEnv, InBndr)
</span><span class="hs-operator hs-var">`seq`</span></span><span> </span><span class="annot"><span class="annottext">(SimplEnv, InBndr) -&gt; SimplM (SimplEnv, InBndr)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958518"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958517"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-746"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680958514"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958514"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680958513"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958513"><span class="hs-identifier hs-var">id</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplEnv -&gt; InBndr -&gt; (SimplEnv, InBndr)
</span><a href="GHC.Core.Opt.Simplify.Env.html#substIdBndr"><span class="hs-identifier hs-var">substIdBndr</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958520"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958519"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-747"></span><span>                        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">InBndr -&gt; ()
</span><a href="GHC.Core.Opt.Simplify.Env.html#seqId"><span class="hs-identifier hs-var">seqId</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958513"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">() -&gt; SimplM (SimplEnv, InBndr) -&gt; SimplM (SimplEnv, InBndr)
</span><span class="hs-operator hs-var">`seq`</span></span><span> </span><span class="annot"><span class="annottext">(SimplEnv, InBndr) -&gt; SimplM (SimplEnv, InBndr)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958514"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958513"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-748"></span><span>
</span><span id="line-749"></span><span class="hs-comment">---------------</span><span>
</span><span id="line-750"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#simplNonRecBndr"><span class="hs-identifier hs-type">simplNonRecBndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#InBndr"><span class="hs-identifier hs-type">InBndr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Monad.html#SimplM"><span class="hs-identifier hs-type">SimplM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#OutBndr"><span class="hs-identifier hs-type">OutBndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-751"></span><span class="hs-comment">-- A non-recursive let binder</span><span>
</span><span id="line-752"></span><span id="simplNonRecBndr"><span class="annot"><span class="annottext">simplNonRecBndr :: SimplEnv -&gt; InBndr -&gt; SimplM (SimplEnv, InBndr)
</span><a href="GHC.Core.Opt.Simplify.Env.html#simplNonRecBndr"><span class="hs-identifier hs-var hs-var">simplNonRecBndr</span></a></span></span><span> </span><span id="local-6989586621680958510"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958510"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680958509"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958509"><span class="hs-identifier hs-var">id</span></a></span></span><span>
</span><span id="line-753"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680958508"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958508"><span class="hs-identifier hs-var">env1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680958507"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958507"><span class="hs-identifier hs-var">id1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplEnv -&gt; InBndr -&gt; (SimplEnv, InBndr)
</span><a href="GHC.Core.Opt.Simplify.Env.html#substIdBndr"><span class="hs-identifier hs-var">substIdBndr</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958510"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958509"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-754"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">InBndr -&gt; ()
</span><a href="GHC.Core.Opt.Simplify.Env.html#seqId"><span class="hs-identifier hs-var">seqId</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958507"><span class="hs-identifier hs-var">id1</span></a></span><span> </span><span class="annot"><span class="annottext">() -&gt; SimplM (SimplEnv, InBndr) -&gt; SimplM (SimplEnv, InBndr)
</span><span class="hs-operator hs-var">`seq`</span></span><span> </span><span class="annot"><span class="annottext">(SimplEnv, InBndr) -&gt; SimplM (SimplEnv, InBndr)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958508"><span class="hs-identifier hs-var">env1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958507"><span class="hs-identifier hs-var">id1</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-755"></span><span>
</span><span id="line-756"></span><span class="hs-comment">---------------</span><span>
</span><span id="line-757"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#simplRecBndrs"><span class="hs-identifier hs-type">simplRecBndrs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#InBndr"><span class="hs-identifier hs-type">InBndr</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Monad.html#SimplM"><span class="hs-identifier hs-type">SimplM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span>
</span><span id="line-758"></span><span class="hs-comment">-- Recursive let binders</span><span>
</span><span id="line-759"></span><span id="simplRecBndrs"><span class="annot"><span class="annottext">simplRecBndrs :: SimplEnv -&gt; [InBndr] -&gt; SimplM SimplEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#simplRecBndrs"><span class="hs-identifier hs-var hs-var">simplRecBndrs</span></a></span></span><span> </span><span id="local-6989586621680958506"><span class="annot"><span class="annottext">env :: SimplEnv
</span><a href="#local-6989586621680958506"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680958505"><span class="annot"><span class="annottext">[InBndr]
</span><a href="#local-6989586621680958505"><span class="hs-identifier hs-var">ids</span></a></span></span><span>
</span><span id="line-760"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span class="hs-identifier">all</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">not</span><span> </span><span class="hs-operator">.</span><span> </span><span class="hs-identifier">isJoinId</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">ids</span><span class="hs-special">)</span><span>
</span><span id="line-761"></span><span>    </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680958502"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958502"><span class="hs-identifier hs-var">env1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680958501"><span class="annot"><span class="annottext">[InBndr]
</span><a href="#local-6989586621680958501"><span class="hs-identifier hs-var">ids1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(SimplEnv -&gt; InBndr -&gt; (SimplEnv, InBndr))
-&gt; SimplEnv -&gt; [InBndr] -&gt; (SimplEnv, [InBndr])
forall (t :: * -&gt; *) s a b.
Traversable t =&gt;
(s -&gt; a -&gt; (s, b)) -&gt; s -&gt; t a -&gt; (s, t b)
</span><a href="../../base/src/Data.Traversable.html#mapAccumL"><span class="hs-identifier hs-var">mapAccumL</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv -&gt; InBndr -&gt; (SimplEnv, InBndr)
</span><a href="GHC.Core.Opt.Simplify.Env.html#substIdBndr"><span class="hs-identifier hs-var">substIdBndr</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958506"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[InBndr]
</span><a href="#local-6989586621680958505"><span class="hs-identifier hs-var">ids</span></a></span><span>
</span><span id="line-762"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[InBndr] -&gt; ()
</span><a href="GHC.Core.Opt.Simplify.Env.html#seqIds"><span class="hs-identifier hs-var">seqIds</span></a></span><span> </span><span class="annot"><span class="annottext">[InBndr]
</span><a href="#local-6989586621680958501"><span class="hs-identifier hs-var">ids1</span></a></span><span> </span><span class="annot"><span class="annottext">() -&gt; SimplM SimplEnv -&gt; SimplM SimplEnv
</span><span class="hs-operator hs-var">`seq`</span></span><span> </span><span class="annot"><span class="annottext">SimplEnv -&gt; SimplM SimplEnv
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958502"><span class="hs-identifier hs-var">env1</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-763"></span><span>
</span><span id="line-764"></span><span>
</span><span id="line-765"></span><span class="hs-comment">---------------</span><span>
</span><span id="line-766"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#substIdBndr"><span class="hs-identifier hs-type">substIdBndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#InBndr"><span class="hs-identifier hs-type">InBndr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#OutBndr"><span class="hs-identifier hs-type">OutBndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-767"></span><span class="hs-comment">-- Might be a coercion variable</span><span>
</span><span id="line-768"></span><span id="substIdBndr"><span class="annot"><span class="annottext">substIdBndr :: SimplEnv -&gt; InBndr -&gt; (SimplEnv, InBndr)
</span><a href="GHC.Core.Opt.Simplify.Env.html#substIdBndr"><span class="hs-identifier hs-var hs-var">substIdBndr</span></a></span></span><span> </span><span id="local-6989586621680958499"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958499"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680958498"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958498"><span class="hs-identifier hs-var">bndr</span></a></span></span><span>
</span><span id="line-769"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">InBndr -&gt; Bool
</span><a href="GHC.Types.Var.html#isCoVar"><span class="hs-identifier hs-var">isCoVar</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958498"><span class="hs-identifier hs-var">bndr</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplEnv -&gt; InBndr -&gt; (SimplEnv, InBndr)
</span><a href="GHC.Core.Opt.Simplify.Env.html#substCoVarBndr"><span class="hs-identifier hs-var">substCoVarBndr</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958499"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958498"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-770"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplEnv -&gt; InBndr -&gt; (SimplEnv, InBndr)
</span><a href="GHC.Core.Opt.Simplify.Env.html#substNonCoVarIdBndr"><span class="hs-identifier hs-var">substNonCoVarIdBndr</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958499"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958498"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-771"></span><span>
</span><span id="line-772"></span><span class="hs-comment">---------------</span><span>
</span><span id="line-773"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#substNonCoVarIdBndr"><span class="hs-identifier hs-type">substNonCoVarIdBndr</span></a></span><span>
</span><span id="line-774"></span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span>
</span><span id="line-775"></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#InBndr"><span class="hs-identifier hs-type">InBndr</span></a></span><span>    </span><span class="hs-comment">-- Env and binder to transform</span><span>
</span><span id="line-776"></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#OutBndr"><span class="hs-identifier hs-type">OutBndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-777"></span><span class="hs-comment">-- Clone Id if necessary, substitute its type</span><span>
</span><span id="line-778"></span><span class="hs-comment">-- Return an Id with its</span><span>
</span><span id="line-779"></span><span class="hs-comment">--      * Type substituted</span><span>
</span><span id="line-780"></span><span class="hs-comment">--      * UnfoldingInfo, Rules, WorkerInfo zapped</span><span>
</span><span id="line-781"></span><span class="hs-comment">--      * Fragile OccInfo (only) zapped: Note [Robust OccInfo]</span><span>
</span><span id="line-782"></span><span class="hs-comment">--      * Robust info, retained especially arity and demand info,</span><span>
</span><span id="line-783"></span><span class="hs-comment">--         so that they are available to occurrences that occur in an</span><span>
</span><span id="line-784"></span><span class="hs-comment">--         earlier binding of a letrec</span><span>
</span><span id="line-785"></span><span class="hs-comment">--</span><span>
</span><span id="line-786"></span><span class="hs-comment">-- For the robust info, see Note [Arity robustness]</span><span>
</span><span id="line-787"></span><span class="hs-comment">--</span><span>
</span><span id="line-788"></span><span class="hs-comment">-- Augment the substitution  if the unique changed</span><span>
</span><span id="line-789"></span><span class="hs-comment">-- Extend the in-scope set with the new Id</span><span>
</span><span id="line-790"></span><span class="hs-comment">--</span><span>
</span><span id="line-791"></span><span class="hs-comment">-- Similar to GHC.Core.Subst.substIdBndr, except that</span><span>
</span><span id="line-792"></span><span class="hs-comment">--      the type of id_subst differs</span><span>
</span><span id="line-793"></span><span class="hs-comment">--      all fragile info is zapped</span><span>
</span><span id="line-794"></span><span id="substNonCoVarIdBndr"><span class="annot"><span class="annottext">substNonCoVarIdBndr :: SimplEnv -&gt; InBndr -&gt; (SimplEnv, InBndr)
</span><a href="GHC.Core.Opt.Simplify.Env.html#substNonCoVarIdBndr"><span class="hs-identifier hs-var hs-var">substNonCoVarIdBndr</span></a></span></span><span> </span><span id="local-6989586621680958495"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958495"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680958494"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958494"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplEnv -&gt; InBndr -&gt; (InBndr -&gt; InBndr) -&gt; (SimplEnv, InBndr)
</span><a href="GHC.Core.Opt.Simplify.Env.html#subst_id_bndr"><span class="hs-identifier hs-var">subst_id_bndr</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958495"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958494"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621680958492"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958492"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958492"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-795"></span><span>
</span><span id="line-796"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#subst_id_bndr"><span class="hs-identifier hs-type">subst_id_bndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span>
</span><span id="line-797"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#InBndr"><span class="hs-identifier hs-type">InBndr</span></a></span><span>    </span><span class="hs-comment">-- Env and binder to transform</span><span>
</span><span id="line-798"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- Adjust the type</span><span>
</span><span id="line-799"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#OutBndr"><span class="hs-identifier hs-type">OutBndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-800"></span><span id="subst_id_bndr"><span class="annot"><span class="annottext">subst_id_bndr :: SimplEnv -&gt; InBndr -&gt; (InBndr -&gt; InBndr) -&gt; (SimplEnv, InBndr)
</span><a href="GHC.Core.Opt.Simplify.Env.html#subst_id_bndr"><span class="hs-identifier hs-var hs-var">subst_id_bndr</span></a></span></span><span> </span><span id="local-6989586621680958491"><span class="annot"><span class="annottext">env :: SimplEnv
</span><a href="#local-6989586621680958491"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">seInScope :: SimplEnv -&gt; InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#seInScope"><span class="hs-identifier hs-var">seInScope</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958490"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958490"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">seIdSubst :: SimplEnv -&gt; SimplIdSubst
</span><a href="GHC.Core.Opt.Simplify.Env.html#seIdSubst"><span class="hs-identifier hs-var">seIdSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958489"><span class="annot"><span class="annottext">SimplIdSubst
</span><a href="#local-6989586621680958489"><span class="hs-identifier hs-var">id_subst</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-801"></span><span>              </span><span id="local-6989586621680958488"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958488"><span class="hs-identifier hs-var">old_id</span></a></span></span><span> </span><span id="local-6989586621680958487"><span class="annot"><span class="annottext">InBndr -&gt; InBndr
</span><a href="#local-6989586621680958487"><span class="hs-identifier hs-var">adjust_type</span></a></span></span><span>
</span><span id="line-802"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">not</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">isCoVar</span><span> </span><span class="hs-identifier">old_id</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">old_id</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-803"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958491"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">seInScope :: InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#seInScope"><span class="hs-identifier hs-var">seInScope</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958490"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; InBndr -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#extendInScopeSet"><span class="hs-operator hs-var">`extendInScopeSet`</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958486"><span class="hs-identifier hs-var">new_id</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-804"></span><span>           </span><span class="annot"><span class="annottext">seIdSubst :: SimplIdSubst
</span><a href="GHC.Core.Opt.Simplify.Env.html#seIdSubst"><span class="hs-identifier hs-var">seIdSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplIdSubst
</span><a href="#local-6989586621680958485"><span class="hs-identifier hs-var">new_subst</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958486"><span class="hs-identifier hs-var">new_id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-805"></span><span>    </span><span class="hs-comment">-- It's important that both seInScope and seIdSubt are updated with</span><span>
</span><span id="line-806"></span><span>    </span><span class="hs-comment">-- the new_id, /after/ applying adjust_type. That's why adjust_type</span><span>
</span><span id="line-807"></span><span>    </span><span class="hs-comment">-- is done here.  If we did adjust_type in simplJoinBndr (the only</span><span>
</span><span id="line-808"></span><span>    </span><span class="hs-comment">-- place that gives a non-identity adjust_type) we'd have to fiddle</span><span>
</span><span id="line-809"></span><span>    </span><span class="hs-comment">-- afresh with both seInScope and seIdSubst</span><span>
</span><span id="line-810"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-811"></span><span>    </span><span id="local-6989586621680958484"><span class="annot"><span class="annottext">id1 :: InBndr
</span><a href="#local-6989586621680958484"><span class="hs-identifier hs-var hs-var">id1</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; InBndr -&gt; InBndr
</span><a href="GHC.Types.Var.Env.html#uniqAway"><span class="hs-identifier hs-var">uniqAway</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958490"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958488"><span class="hs-identifier hs-var">old_id</span></a></span><span>
</span><span id="line-812"></span><span>    </span><span id="local-6989586621680958482"><span class="annot"><span class="annottext">id2 :: InBndr
</span><a href="#local-6989586621680958482"><span class="hs-identifier hs-var hs-var">id2</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplEnv -&gt; InBndr -&gt; InBndr
</span><a href="GHC.Core.Opt.Simplify.Env.html#substIdType"><span class="hs-identifier hs-var">substIdType</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958491"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958484"><span class="hs-identifier hs-var">id1</span></a></span><span>
</span><span id="line-813"></span><span>    </span><span id="local-6989586621680958480"><span class="annot"><span class="annottext">id3 :: InBndr
</span><a href="#local-6989586621680958480"><span class="hs-identifier hs-var hs-var">id3</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InBndr -&gt; InBndr
</span><a href="GHC.Types.Id.html#zapFragileIdInfo"><span class="hs-identifier hs-var">zapFragileIdInfo</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958482"><span class="hs-identifier hs-var">id2</span></a></span><span>       </span><span class="hs-comment">-- Zaps rules, worker-info, unfolding</span><span>
</span><span id="line-814"></span><span>                                      </span><span class="hs-comment">-- and fragile OccInfo</span><span>
</span><span id="line-815"></span><span>    </span><span id="local-6989586621680958486"><span class="annot"><span class="annottext">new_id :: InBndr
</span><a href="#local-6989586621680958486"><span class="hs-identifier hs-var hs-var">new_id</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InBndr -&gt; InBndr
</span><a href="#local-6989586621680958487"><span class="hs-identifier hs-var">adjust_type</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958480"><span class="hs-identifier hs-var">id3</span></a></span><span>
</span><span id="line-816"></span><span>
</span><span id="line-817"></span><span>        </span><span class="hs-comment">-- Extend the substitution if the unique has changed,</span><span>
</span><span id="line-818"></span><span>        </span><span class="hs-comment">-- or there's some useful occurrence information</span><span>
</span><span id="line-819"></span><span>        </span><span class="hs-comment">-- See the notes with substTyVarBndr for the delSubstEnv</span><span>
</span><span id="line-820"></span><span>    </span><span id="local-6989586621680958485"><span class="annot"><span class="annottext">new_subst :: SimplIdSubst
</span><a href="#local-6989586621680958485"><span class="hs-identifier hs-var hs-var">new_subst</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958486"><span class="hs-identifier hs-var">new_id</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr -&gt; InBndr -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958488"><span class="hs-identifier hs-var">old_id</span></a></span><span>
</span><span id="line-821"></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplIdSubst -&gt; InBndr -&gt; SimplSR -&gt; SimplIdSubst
forall a. VarEnv a -&gt; InBndr -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">SimplIdSubst
</span><a href="#local-6989586621680958489"><span class="hs-identifier hs-var">id_subst</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958488"><span class="hs-identifier hs-var">old_id</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InBndr -&gt; SimplSR
</span><a href="GHC.Core.Opt.Simplify.Env.html#DoneId"><span class="hs-identifier hs-var">DoneId</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958486"><span class="hs-identifier hs-var">new_id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-822"></span><span>              </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-823"></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplIdSubst -&gt; InBndr -&gt; SimplIdSubst
forall a. VarEnv a -&gt; InBndr -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#delVarEnv"><span class="hs-identifier hs-var">delVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">SimplIdSubst
</span><a href="#local-6989586621680958489"><span class="hs-identifier hs-var">id_subst</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958488"><span class="hs-identifier hs-var">old_id</span></a></span><span>
</span><span id="line-824"></span><span>
</span><span id="line-825"></span><span class="hs-comment">------------------------------------</span><span>
</span><span id="line-826"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#seqTyVar"><span class="hs-identifier hs-type">seqTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-827"></span><span id="seqTyVar"><span class="annot"><span class="annottext">seqTyVar :: InBndr -&gt; ()
</span><a href="GHC.Core.Opt.Simplify.Env.html#seqTyVar"><span class="hs-identifier hs-var hs-var">seqTyVar</span></a></span></span><span> </span><span id="local-6989586621680958474"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958474"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958474"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr -&gt; () -&gt; ()
</span><span class="hs-operator hs-var">`seq`</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-828"></span><span>
</span><span id="line-829"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#seqId"><span class="hs-identifier hs-type">seqId</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-830"></span><span id="seqId"><span class="annot"><span class="annottext">seqId :: InBndr -&gt; ()
</span><a href="GHC.Core.Opt.Simplify.Env.html#seqId"><span class="hs-identifier hs-var hs-var">seqId</span></a></span></span><span> </span><span id="local-6989586621680958473"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958473"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; ()
</span><a href="GHC.Core.Type.html#seqType"><span class="hs-identifier hs-var">seqType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InBndr -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958473"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span>  </span><span class="annot"><span class="annottext">() -&gt; () -&gt; ()
</span><span class="hs-operator hs-var">`seq`</span></span><span>
</span><span id="line-831"></span><span>           </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; InBndr -&gt; IdInfo
InBndr -&gt; IdInfo
</span><a href="GHC.Types.Var.html#idInfo"><span class="hs-identifier hs-var">idInfo</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958473"><span class="hs-identifier hs-var">id</span></a></span><span>            </span><span class="annot"><span class="annottext">IdInfo -&gt; () -&gt; ()
</span><span class="hs-operator hs-var">`seq`</span></span><span>
</span><span id="line-832"></span><span>           </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-833"></span><span>
</span><span id="line-834"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#seqIds"><span class="hs-identifier hs-type">seqIds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-835"></span><span id="seqIds"><span class="annot"><span class="annottext">seqIds :: [InBndr] -&gt; ()
</span><a href="GHC.Core.Opt.Simplify.Env.html#seqIds"><span class="hs-identifier hs-var hs-var">seqIds</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-836"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#seqIds"><span class="hs-identifier hs-var">seqIds</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680958470"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958470"><span class="hs-identifier hs-var">id</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680958469"><span class="annot"><span class="annottext">[InBndr]
</span><a href="#local-6989586621680958469"><span class="hs-identifier hs-var">ids</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InBndr -&gt; ()
</span><a href="GHC.Core.Opt.Simplify.Env.html#seqId"><span class="hs-identifier hs-var">seqId</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958470"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">() -&gt; () -&gt; ()
</span><span class="hs-operator hs-var">`seq`</span></span><span> </span><span class="annot"><span class="annottext">[InBndr] -&gt; ()
</span><a href="GHC.Core.Opt.Simplify.Env.html#seqIds"><span class="hs-identifier hs-var">seqIds</span></a></span><span> </span><span class="annot"><span class="annottext">[InBndr]
</span><a href="#local-6989586621680958469"><span class="hs-identifier hs-var">ids</span></a></span><span>
</span><span id="line-837"></span><span>
</span><span id="line-838"></span><span class="hs-comment">{-
Note [Arity robustness]
~~~~~~~~~~~~~~~~~~~~~~~
We *do* transfer the arity from the in_id of a let binding to the
out_id.  This is important, so that the arity of an Id is visible in
its own RHS.  For example:
        f = \x. ....g (\y. f y)....
We can eta-reduce the arg to g, because f is a value.  But that
needs to be visible.

This interacts with the 'state hack' too:
        f :: Bool -&gt; IO Int
        f = \x. case x of
                  True  -&gt; f y
                  False -&gt; \s -&gt; ...
Can we eta-expand f?  Only if we see that f has arity 1, and then we
take advantage of the 'state hack' on the result of
(f y) :: State# -&gt; (State#, Int) to expand the arity one more.

There is a disadvantage though.  Making the arity visible in the RHS
allows us to eta-reduce
        f = \x -&gt; f x
to
        f = f
which technically is not sound.   This is very much a corner case, so
I'm not worried about it.  Another idea is to ensure that f's arity
never decreases; its arity started as 1, and we should never eta-reduce
below that.


Note [Robust OccInfo]
~~~~~~~~~~~~~~~~~~~~~
It's important that we *do* retain the loop-breaker OccInfo, because
that's what stops the Id getting inlined infinitely, in the body of
the letrec.
-}</span><span>
</span><span id="line-874"></span><span>
</span><span id="line-875"></span><span>
</span><span id="line-876"></span><span class="hs-comment">{- *********************************************************************
*                                                                      *
                Join points
*                                                                      *
********************************************************************* -}</span><span>
</span><span id="line-881"></span><span>
</span><span id="line-882"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#simplNonRecJoinBndr"><span class="hs-identifier hs-type">simplNonRecJoinBndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#InBndr"><span class="hs-identifier hs-type">InBndr</span></a></span><span>
</span><span id="line-883"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Mult"><span class="hs-identifier hs-type">Mult</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#OutType"><span class="hs-identifier hs-type">OutType</span></a></span><span>
</span><span id="line-884"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Monad.html#SimplM"><span class="hs-identifier hs-type">SimplM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#OutBndr"><span class="hs-identifier hs-type">OutBndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-885"></span><span>
</span><span id="line-886"></span><span class="hs-comment">-- A non-recursive let binder for a join point;</span><span>
</span><span id="line-887"></span><span class="hs-comment">-- context being pushed inward may change the type</span><span>
</span><span id="line-888"></span><span class="hs-comment">-- See Note [Return type for join points]</span><span>
</span><span id="line-889"></span><span id="simplNonRecJoinBndr"><span class="annot"><span class="annottext">simplNonRecJoinBndr :: SimplEnv -&gt; InBndr -&gt; Type -&gt; Type -&gt; SimplM (SimplEnv, InBndr)
</span><a href="GHC.Core.Opt.Simplify.Env.html#simplNonRecJoinBndr"><span class="hs-identifier hs-var hs-var">simplNonRecJoinBndr</span></a></span></span><span> </span><span id="local-6989586621680958466"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958466"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680958465"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958465"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span id="local-6989586621680958464"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958464"><span class="hs-identifier hs-var">mult</span></a></span></span><span> </span><span id="local-6989586621680958463"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958463"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span>
</span><span id="line-890"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680958462"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958462"><span class="hs-identifier hs-var">env1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680958461"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958461"><span class="hs-identifier hs-var">id1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; SimplEnv -&gt; InBndr -&gt; (SimplEnv, InBndr)
</span><a href="GHC.Core.Opt.Simplify.Env.html#simplJoinBndr"><span class="hs-identifier hs-var">simplJoinBndr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958464"><span class="hs-identifier hs-var">mult</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958463"><span class="hs-identifier hs-var">res_ty</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958466"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958465"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-891"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">InBndr -&gt; ()
</span><a href="GHC.Core.Opt.Simplify.Env.html#seqId"><span class="hs-identifier hs-var">seqId</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958461"><span class="hs-identifier hs-var">id1</span></a></span><span> </span><span class="annot"><span class="annottext">() -&gt; SimplM (SimplEnv, InBndr) -&gt; SimplM (SimplEnv, InBndr)
</span><span class="hs-operator hs-var">`seq`</span></span><span> </span><span class="annot"><span class="annottext">(SimplEnv, InBndr) -&gt; SimplM (SimplEnv, InBndr)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958462"><span class="hs-identifier hs-var">env1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958461"><span class="hs-identifier hs-var">id1</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-892"></span><span>
</span><span id="line-893"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#simplRecJoinBndrs"><span class="hs-identifier hs-type">simplRecJoinBndrs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#InBndr"><span class="hs-identifier hs-type">InBndr</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-894"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Mult"><span class="hs-identifier hs-type">Mult</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#OutType"><span class="hs-identifier hs-type">OutType</span></a></span><span>
</span><span id="line-895"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Monad.html#SimplM"><span class="hs-identifier hs-type">SimplM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span>
</span><span id="line-896"></span><span class="hs-comment">-- Recursive let binders for join points;</span><span>
</span><span id="line-897"></span><span class="hs-comment">-- context being pushed inward may change types</span><span>
</span><span id="line-898"></span><span class="hs-comment">-- See Note [Return type for join points]</span><span>
</span><span id="line-899"></span><span id="simplRecJoinBndrs"><span class="annot"><span class="annottext">simplRecJoinBndrs :: SimplEnv -&gt; [InBndr] -&gt; Type -&gt; Type -&gt; SimplM SimplEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#simplRecJoinBndrs"><span class="hs-identifier hs-var hs-var">simplRecJoinBndrs</span></a></span></span><span> </span><span id="local-6989586621680958459"><span class="annot"><span class="annottext">env :: SimplEnv
</span><a href="#local-6989586621680958459"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680958458"><span class="annot"><span class="annottext">[InBndr]
</span><a href="#local-6989586621680958458"><span class="hs-identifier hs-var">ids</span></a></span></span><span> </span><span id="local-6989586621680958457"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958457"><span class="hs-identifier hs-var">mult</span></a></span></span><span> </span><span id="local-6989586621680958456"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958456"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span>
</span><span id="line-900"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span class="hs-identifier">all</span><span> </span><span class="hs-identifier">isJoinId</span><span> </span><span class="hs-identifier">ids</span><span class="hs-special">)</span><span>
</span><span id="line-901"></span><span>    </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680958454"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958454"><span class="hs-identifier hs-var">env1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680958453"><span class="annot"><span class="annottext">[InBndr]
</span><a href="#local-6989586621680958453"><span class="hs-identifier hs-var">ids1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(SimplEnv -&gt; InBndr -&gt; (SimplEnv, InBndr))
-&gt; SimplEnv -&gt; [InBndr] -&gt; (SimplEnv, [InBndr])
forall (t :: * -&gt; *) s a b.
Traversable t =&gt;
(s -&gt; a -&gt; (s, b)) -&gt; s -&gt; t a -&gt; (s, t b)
</span><a href="../../base/src/Data.Traversable.html#mapAccumL"><span class="hs-identifier hs-var">mapAccumL</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; SimplEnv -&gt; InBndr -&gt; (SimplEnv, InBndr)
</span><a href="GHC.Core.Opt.Simplify.Env.html#simplJoinBndr"><span class="hs-identifier hs-var">simplJoinBndr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958457"><span class="hs-identifier hs-var">mult</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958456"><span class="hs-identifier hs-var">res_ty</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958459"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[InBndr]
</span><a href="#local-6989586621680958458"><span class="hs-identifier hs-var">ids</span></a></span><span>
</span><span id="line-902"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[InBndr] -&gt; ()
</span><a href="GHC.Core.Opt.Simplify.Env.html#seqIds"><span class="hs-identifier hs-var">seqIds</span></a></span><span> </span><span class="annot"><span class="annottext">[InBndr]
</span><a href="#local-6989586621680958453"><span class="hs-identifier hs-var">ids1</span></a></span><span> </span><span class="annot"><span class="annottext">() -&gt; SimplM SimplEnv -&gt; SimplM SimplEnv
</span><span class="hs-operator hs-var">`seq`</span></span><span> </span><span class="annot"><span class="annottext">SimplEnv -&gt; SimplM SimplEnv
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958454"><span class="hs-identifier hs-var">env1</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-903"></span><span>
</span><span id="line-904"></span><span class="hs-comment">---------------</span><span>
</span><span id="line-905"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#simplJoinBndr"><span class="hs-identifier hs-type">simplJoinBndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Mult"><span class="hs-identifier hs-type">Mult</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#OutType"><span class="hs-identifier hs-type">OutType</span></a></span><span>
</span><span id="line-906"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#InBndr"><span class="hs-identifier hs-type">InBndr</span></a></span><span>
</span><span id="line-907"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#OutBndr"><span class="hs-identifier hs-type">OutBndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-908"></span><span id="simplJoinBndr"><span class="annot"><span class="annottext">simplJoinBndr :: Type -&gt; Type -&gt; SimplEnv -&gt; InBndr -&gt; (SimplEnv, InBndr)
</span><a href="GHC.Core.Opt.Simplify.Env.html#simplJoinBndr"><span class="hs-identifier hs-var hs-var">simplJoinBndr</span></a></span></span><span> </span><span id="local-6989586621680958452"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958452"><span class="hs-identifier hs-var">mult</span></a></span></span><span> </span><span id="local-6989586621680958451"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958451"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span> </span><span id="local-6989586621680958450"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958450"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680958449"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958449"><span class="hs-identifier hs-var">id</span></a></span></span><span>
</span><span id="line-909"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SimplEnv -&gt; InBndr -&gt; (InBndr -&gt; InBndr) -&gt; (SimplEnv, InBndr)
</span><a href="GHC.Core.Opt.Simplify.Env.html#subst_id_bndr"><span class="hs-identifier hs-var">subst_id_bndr</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958450"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958449"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; InBndr -&gt; InBndr
</span><a href="GHC.Core.Opt.Simplify.Env.html#adjustJoinPointType"><span class="hs-identifier hs-var">adjustJoinPointType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958452"><span class="hs-identifier hs-var">mult</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958451"><span class="hs-identifier hs-var">res_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-910"></span><span>
</span><span id="line-911"></span><span class="hs-comment">---------------</span><span>
</span><span id="line-912"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#adjustJoinPointType"><span class="hs-identifier hs-type">adjustJoinPointType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Mult"><span class="hs-identifier hs-type">Mult</span></a></span><span>
</span><span id="line-913"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>     </span><span class="hs-comment">-- New result type</span><span>
</span><span id="line-914"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>       </span><span class="hs-comment">-- Old join-point Id</span><span>
</span><span id="line-915"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>       </span><span class="hs-comment">-- Adjusted jont-point Id</span><span>
</span><span id="line-916"></span><span class="hs-comment">-- (adjustJoinPointType mult new_res_ty join_id) does two things:</span><span>
</span><span id="line-917"></span><span class="hs-comment">--</span><span>
</span><span id="line-918"></span><span class="hs-comment">--   1. Set the return type of the join_id to new_res_ty</span><span>
</span><span id="line-919"></span><span class="hs-comment">--      See Note [Return type for join points]</span><span>
</span><span id="line-920"></span><span class="hs-comment">--</span><span>
</span><span id="line-921"></span><span class="hs-comment">--   2. Adjust the multiplicity of arrows in join_id's type, as</span><span>
</span><span id="line-922"></span><span class="hs-comment">--      directed by 'mult'. See Note [Scaling join point arguments]</span><span>
</span><span id="line-923"></span><span class="hs-comment">--</span><span>
</span><span id="line-924"></span><span class="hs-comment">-- INVARIANT: If any of the first n binders are foralls, those tyvars</span><span>
</span><span id="line-925"></span><span class="hs-comment">-- cannot appear in the original result type. See isValidJoinPointType.</span><span>
</span><span id="line-926"></span><span id="adjustJoinPointType"><span class="annot"><span class="annottext">adjustJoinPointType :: Type -&gt; Type -&gt; InBndr -&gt; InBndr
</span><a href="GHC.Core.Opt.Simplify.Env.html#adjustJoinPointType"><span class="hs-identifier hs-var hs-var">adjustJoinPointType</span></a></span></span><span> </span><span id="local-6989586621680958447"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958447"><span class="hs-identifier hs-var">mult</span></a></span></span><span> </span><span id="local-6989586621680958446"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958446"><span class="hs-identifier hs-var">new_res_ty</span></a></span></span><span> </span><span id="local-6989586621680958445"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958445"><span class="hs-identifier hs-var">join_id</span></a></span></span><span>
</span><span id="line-927"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isJoinId</span><span> </span><span class="hs-identifier">join_id</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-928"></span><span>    </span><span class="annot"><span class="annottext">InBndr -&gt; Type -&gt; InBndr
</span><a href="GHC.Types.Id.html#setIdType"><span class="hs-identifier hs-var">setIdType</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958445"><span class="hs-identifier hs-var">join_id</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958443"><span class="hs-identifier hs-var">new_join_ty</span></a></span><span>
</span><span id="line-929"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-930"></span><span>    </span><span id="local-6989586621680958442"><span class="annot"><span class="annottext">orig_ar :: JoinArity
</span><a href="#local-6989586621680958442"><span class="hs-identifier hs-var hs-var">orig_ar</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InBndr -&gt; JoinArity
</span><a href="GHC.Types.Id.html#idJoinArity"><span class="hs-identifier hs-var">idJoinArity</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958445"><span class="hs-identifier hs-var">join_id</span></a></span><span>
</span><span id="line-931"></span><span>    </span><span id="local-6989586621680958440"><span class="annot"><span class="annottext">orig_ty :: Type
</span><a href="#local-6989586621680958440"><span class="hs-identifier hs-var hs-var">orig_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InBndr -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958445"><span class="hs-identifier hs-var">join_id</span></a></span><span>
</span><span id="line-932"></span><span>
</span><span id="line-933"></span><span>    </span><span id="local-6989586621680958443"><span class="annot"><span class="annottext">new_join_ty :: Type
</span><a href="#local-6989586621680958443"><span class="hs-identifier hs-var hs-var">new_join_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; Type -&gt; Type
forall {t}. (Eq t, Num t) =&gt; t -&gt; Type -&gt; Type
</span><a href="#local-6989586621680958435"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680958442"><span class="hs-identifier hs-var">orig_ar</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958440"><span class="hs-identifier hs-var">orig_ty</span></a></span><span>
</span><span id="line-934"></span><span>
</span><span id="line-935"></span><span>    </span><span id="local-6989586621680958435"><span class="annot"><span class="annottext">go :: t -&gt; Type -&gt; Type
</span><a href="#local-6989586621680958435"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="annot"><span class="annottext">t
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958446"><span class="hs-identifier hs-var">new_res_ty</span></a></span><span>
</span><span id="line-936"></span><span>    </span><span class="annot"><a href="#local-6989586621680958435"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621680958423"><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621680958423"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621680958422"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958422"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680958421"><span class="annot"><span class="annottext">TyCoBinder
</span><a href="#local-6989586621680958421"><span class="hs-identifier hs-var">arg_bndr</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680958420"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958420"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe (TyCoBinder, Type)
</span><a href="GHC.Core.Type.html#splitPiTy_maybe"><span class="hs-identifier hs-var">splitPiTy_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958422"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-937"></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCoBinder -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkPiTy"><span class="hs-identifier hs-var">mkPiTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCoBinder -&gt; TyCoBinder
</span><a href="#local-6989586621680958417"><span class="hs-identifier hs-var">scale_bndr</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoBinder
</span><a href="#local-6989586621680958421"><span class="hs-identifier hs-var">arg_bndr</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Type) -&gt; Type -&gt; Type
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-938"></span><span>              </span><span class="annot"><span class="annottext">t -&gt; Type -&gt; Type
</span><a href="#local-6989586621680958435"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621680958423"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">t -&gt; t -&gt; t
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">t
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958420"><span class="hs-identifier hs-var">res_ty</span></a></span><span>
</span><span id="line-939"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-940"></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; Type
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;adjustJoinPointType&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680958442"><span class="hs-identifier hs-var">orig_ar</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958440"><span class="hs-identifier hs-var">orig_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-941"></span><span>
</span><span id="line-942"></span><span>    </span><span id="local-6989586621680958417"><span class="annot"><span class="annottext">scale_bndr :: TyCoBinder -&gt; TyCoBinder
</span><a href="#local-6989586621680958417"><span class="hs-identifier hs-var hs-var">scale_bndr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Anon"><span class="hs-identifier hs-type">Anon</span></a></span><span> </span><span id="local-6989586621680958415"><span class="annot"><span class="annottext">AnonArgFlag
</span><a href="#local-6989586621680958415"><span class="hs-identifier hs-var">af</span></a></span></span><span> </span><span id="local-6989586621680958414"><span class="annot"><span class="annottext">Scaled Type
</span><a href="#local-6989586621680958414"><span class="hs-identifier hs-var">t</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnonArgFlag -&gt; Scaled Type -&gt; TyCoBinder
</span><a href="GHC.Core.TyCo.Rep.html#Anon"><span class="hs-identifier hs-var">Anon</span></a></span><span> </span><span class="annot"><span class="annottext">AnonArgFlag
</span><a href="#local-6989586621680958415"><span class="hs-identifier hs-var">af</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Scaled Type -&gt; Scaled Type
forall a. Type -&gt; Scaled a -&gt; Scaled a
</span><a href="GHC.Core.Multiplicity.html#scaleScaled"><span class="hs-identifier hs-var">scaleScaled</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958447"><span class="hs-identifier hs-var">mult</span></a></span><span> </span><span class="annot"><span class="annottext">Scaled Type
</span><a href="#local-6989586621680958414"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-943"></span><span>    </span><span class="annot"><a href="#local-6989586621680958417"><span class="hs-identifier hs-var">scale_bndr</span></a></span><span> </span><span id="local-6989586621680958413"><span class="annot"><span class="annottext">b :: TyCoBinder
</span><a href="#local-6989586621680958413"><span class="hs-identifier hs-var">b</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Named"><span class="hs-identifier hs-type">Named</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVarBinder
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCoBinder
</span><a href="#local-6989586621680958413"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-944"></span><span>
</span><span id="line-945"></span><span class="hs-comment">{- Note [Scaling join point arguments]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider a join point which is linear in its variable, in some context E:

E[join j :: a %1 -&gt; a
       j x = x
  in case v of
       A -&gt; j 'x'
       B -&gt; &lt;blah&gt;]

The simplifier changes to:

join j :: a %1 -&gt; a
     j x = E[x]
in case v of
     A -&gt; j 'x'
     B -&gt; E[&lt;blah&gt;]

If E uses its argument in a nonlinear way (e.g. a case['Many]), then
this is wrong: the join point has to change its type to a -&gt; a.
Otherwise, we'd get a linearity error.

See also Note [Return type for join points] and Note [Join points and case-of-case].
-}</span><span>
</span><span id="line-969"></span><span>
</span><span id="line-970"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
                Impedance matching to type substitution
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-977"></span><span>
</span><span id="line-978"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#getTCvSubst"><span class="hs-identifier hs-type">getTCvSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-979"></span><span id="getTCvSubst"><span class="annot"><span class="annottext">getTCvSubst :: SimplEnv -&gt; TCvSubst
</span><a href="GHC.Core.Opt.Simplify.Env.html#getTCvSubst"><span class="hs-identifier hs-var hs-var">getTCvSubst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">seInScope :: SimplEnv -&gt; InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#seInScope"><span class="hs-identifier hs-var">seInScope</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958411"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958411"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">seTvSubst :: SimplEnv -&gt; TvSubstEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#seTvSubst"><span class="hs-identifier hs-var">seTvSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958410"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680958410"><span class="hs-identifier hs-var">tv_env</span></a></span></span><span>
</span><span id="line-980"></span><span>                      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">seCvSubst :: SimplEnv -&gt; CvSubstEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#seCvSubst"><span class="hs-identifier hs-var">seCvSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958409"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680958409"><span class="hs-identifier hs-var">cv_env</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-981"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; (TvSubstEnv, CvSubstEnv) -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#mkTCvSubst"><span class="hs-identifier hs-var">mkTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958411"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680958410"><span class="hs-identifier hs-var">tv_env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680958409"><span class="hs-identifier hs-var">cv_env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-982"></span><span>
</span><span id="line-983"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#substTy"><span class="hs-identifier hs-type">substTy</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-984"></span><span id="substTy"><span class="annot"><span class="annottext">substTy :: SimplEnv -&gt; Type -&gt; Type
</span><a href="GHC.Core.Opt.Simplify.Env.html#substTy"><span class="hs-identifier hs-var hs-var">substTy</span></a></span></span><span> </span><span id="local-6989586621680958407"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958407"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680958406"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958406"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Type -&gt; Type
TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-var">Type.substTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SimplEnv -&gt; TCvSubst
</span><a href="GHC.Core.Opt.Simplify.Env.html#getTCvSubst"><span class="hs-identifier hs-var">getTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958407"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958406"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-985"></span><span>
</span><span id="line-986"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#substTyVar"><span class="hs-identifier hs-type">substTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-987"></span><span id="substTyVar"><span class="annot"><span class="annottext">substTyVar :: SimplEnv -&gt; InBndr -&gt; Type
</span><a href="GHC.Core.Opt.Simplify.Env.html#substTyVar"><span class="hs-identifier hs-var hs-var">substTyVar</span></a></span></span><span> </span><span id="local-6989586621680958405"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958405"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680958404"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958404"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; InBndr -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTyVar"><span class="hs-identifier hs-var">Type.substTyVar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SimplEnv -&gt; TCvSubst
</span><a href="GHC.Core.Opt.Simplify.Env.html#getTCvSubst"><span class="hs-identifier hs-var">getTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958405"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958404"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-988"></span><span>
</span><span id="line-989"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#substTyVarBndr"><span class="hs-identifier hs-type">substTyVarBndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-990"></span><span id="substTyVarBndr"><span class="annot"><span class="annottext">substTyVarBndr :: SimplEnv -&gt; InBndr -&gt; (SimplEnv, InBndr)
</span><a href="GHC.Core.Opt.Simplify.Env.html#substTyVarBndr"><span class="hs-identifier hs-var hs-var">substTyVarBndr</span></a></span></span><span> </span><span id="local-6989586621680958403"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958403"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680958402"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958402"><span class="hs-identifier hs-var">tv</span></a></span></span><span>
</span><span id="line-991"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; InBndr -&gt; (TCvSubst, InBndr)
TCvSubst -&gt; InBndr -&gt; (TCvSubst, InBndr)
</span><a href="GHC.Core.TyCo.Subst.html#substTyVarBndr"><span class="hs-identifier hs-var">Type.substTyVarBndr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SimplEnv -&gt; TCvSubst
</span><a href="GHC.Core.Opt.Simplify.Env.html#getTCvSubst"><span class="hs-identifier hs-var">getTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958403"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958402"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-992"></span><span>        </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680958400"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958400"><span class="hs-identifier hs-var">in_scope'</span></a></span></span><span> </span><span id="local-6989586621680958399"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680958399"><span class="hs-identifier hs-var">tv_env'</span></a></span></span><span> </span><span id="local-6989586621680958398"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680958398"><span class="hs-identifier hs-var">cv_env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680958397"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958397"><span class="hs-identifier hs-var">tv'</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-993"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958403"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">seInScope :: InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#seInScope"><span class="hs-identifier hs-var">seInScope</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958400"><span class="hs-identifier hs-var">in_scope'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">seTvSubst :: TvSubstEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#seTvSubst"><span class="hs-identifier hs-var">seTvSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680958399"><span class="hs-identifier hs-var">tv_env'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">seCvSubst :: CvSubstEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#seCvSubst"><span class="hs-identifier hs-var">seCvSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680958398"><span class="hs-identifier hs-var">cv_env'</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958397"><span class="hs-identifier hs-var">tv'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-994"></span><span>
</span><span id="line-995"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#substCoVar"><span class="hs-identifier hs-type">substCoVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>
</span><span id="line-996"></span><span id="substCoVar"><span class="annot"><span class="annottext">substCoVar :: SimplEnv -&gt; InBndr -&gt; Coercion
</span><a href="GHC.Core.Opt.Simplify.Env.html#substCoVar"><span class="hs-identifier hs-var hs-var">substCoVar</span></a></span></span><span> </span><span id="local-6989586621680958396"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958396"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680958395"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958395"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; InBndr -&gt; Coercion
</span><a href="GHC.Core.TyCo.Subst.html#substCoVar"><span class="hs-identifier hs-var">Coercion.substCoVar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SimplEnv -&gt; TCvSubst
</span><a href="GHC.Core.Opt.Simplify.Env.html#getTCvSubst"><span class="hs-identifier hs-var">getTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958396"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958395"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-997"></span><span>
</span><span id="line-998"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#substCoVarBndr"><span class="hs-identifier hs-type">substCoVarBndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-999"></span><span id="substCoVarBndr"><span class="annot"><span class="annottext">substCoVarBndr :: SimplEnv -&gt; InBndr -&gt; (SimplEnv, InBndr)
</span><a href="GHC.Core.Opt.Simplify.Env.html#substCoVarBndr"><span class="hs-identifier hs-var hs-var">substCoVarBndr</span></a></span></span><span> </span><span id="local-6989586621680958394"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958394"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680958393"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958393"><span class="hs-identifier hs-var">cv</span></a></span></span><span>
</span><span id="line-1000"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; InBndr -&gt; (TCvSubst, InBndr)
TCvSubst -&gt; InBndr -&gt; (TCvSubst, InBndr)
</span><a href="GHC.Core.TyCo.Subst.html#substCoVarBndr"><span class="hs-identifier hs-var">Coercion.substCoVarBndr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SimplEnv -&gt; TCvSubst
</span><a href="GHC.Core.Opt.Simplify.Env.html#getTCvSubst"><span class="hs-identifier hs-var">getTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958394"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958393"><span class="hs-identifier hs-var">cv</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1001"></span><span>        </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680958392"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958392"><span class="hs-identifier hs-var">in_scope'</span></a></span></span><span> </span><span id="local-6989586621680958391"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680958391"><span class="hs-identifier hs-var">tv_env'</span></a></span></span><span> </span><span id="local-6989586621680958390"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680958390"><span class="hs-identifier hs-var">cv_env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680958389"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958389"><span class="hs-identifier hs-var">cv'</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1002"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958394"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">seInScope :: InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#seInScope"><span class="hs-identifier hs-var">seInScope</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958392"><span class="hs-identifier hs-var">in_scope'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">seTvSubst :: TvSubstEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#seTvSubst"><span class="hs-identifier hs-var">seTvSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680958391"><span class="hs-identifier hs-var">tv_env'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">seCvSubst :: CvSubstEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#seCvSubst"><span class="hs-identifier hs-var">seCvSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680958390"><span class="hs-identifier hs-var">cv_env'</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958389"><span class="hs-identifier hs-var">cv'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1003"></span><span>
</span><span id="line-1004"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#substCo"><span class="hs-identifier hs-type">substCo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>
</span><span id="line-1005"></span><span id="substCo"><span class="annot"><span class="annottext">substCo :: SimplEnv -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Opt.Simplify.Env.html#substCo"><span class="hs-identifier hs-var hs-var">substCo</span></a></span></span><span> </span><span id="local-6989586621680958388"><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958388"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680958387"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680958387"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Coercion -&gt; Coercion
TCvSubst -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.TyCo.Subst.html#substCo"><span class="hs-identifier hs-var">Coercion.substCo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SimplEnv -&gt; TCvSubst
</span><a href="GHC.Core.Opt.Simplify.Env.html#getTCvSubst"><span class="hs-identifier hs-var">getTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">SimplEnv
</span><a href="#local-6989586621680958388"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680958387"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-1006"></span><span>
</span><span id="line-1007"></span><span class="hs-comment">------------------</span><span>
</span><span id="line-1008"></span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#substIdType"><span class="hs-identifier hs-type">substIdType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-1009"></span><span id="substIdType"><span class="annot"><span class="annottext">substIdType :: SimplEnv -&gt; InBndr -&gt; InBndr
</span><a href="GHC.Core.Opt.Simplify.Env.html#substIdType"><span class="hs-identifier hs-var hs-var">substIdType</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Simplify.Env.html#SimplEnv"><span class="hs-identifier hs-type">SimplEnv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">seInScope :: SimplEnv -&gt; InScopeSet
</span><a href="GHC.Core.Opt.Simplify.Env.html#seInScope"><span class="hs-identifier hs-var">seInScope</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958386"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958386"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">seTvSubst :: SimplEnv -&gt; TvSubstEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#seTvSubst"><span class="hs-identifier hs-var">seTvSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958385"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680958385"><span class="hs-identifier hs-var">tv_env</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">seCvSubst :: SimplEnv -&gt; CvSubstEnv
</span><a href="GHC.Core.Opt.Simplify.Env.html#seCvSubst"><span class="hs-identifier hs-var">seCvSubst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680958384"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680958384"><span class="hs-identifier hs-var">cv_env</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680958383"><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958383"><span class="hs-identifier hs-var">id</span></a></span></span><span>
</span><span id="line-1010"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TvSubstEnv -&gt; Bool
forall a. VarEnv a -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#isEmptyVarEnv"><span class="hs-identifier hs-var">isEmptyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680958385"><span class="hs-identifier hs-var">tv_env</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; Bool
forall a. VarEnv a -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#isEmptyVarEnv"><span class="hs-identifier hs-var">isEmptyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680958384"><span class="hs-identifier hs-var">cv_env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1011"></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680958381"><span class="hs-identifier hs-var">no_free_vars</span></a></span><span>
</span><span id="line-1012"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958383"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-1013"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Type) -&gt; InBndr -&gt; InBndr
</span><a href="GHC.Types.Var.html#updateIdTypeAndMult"><span class="hs-identifier hs-var">Id.updateIdTypeAndMult</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTyUnchecked"><span class="hs-identifier hs-var">Type.substTyUnchecked</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680958378"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958383"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-1014"></span><span>                </span><span class="hs-comment">-- The tyCoVarsOfType is cheaper than it looks</span><span>
</span><span id="line-1015"></span><span>                </span><span class="hs-comment">-- because we cache the free tyvars of the type</span><span>
</span><span id="line-1016"></span><span>                </span><span class="hs-comment">-- in a Note in the id's type itself</span><span>
</span><span id="line-1017"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1018"></span><span>    </span><span id="local-6989586621680958381"><span class="annot"><span class="annottext">no_free_vars :: Bool
</span><a href="#local-6989586621680958381"><span class="hs-identifier hs-var hs-var">no_free_vars</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Core.TyCo.FVs.html#noFreeVarsOfType"><span class="hs-identifier hs-var">noFreeVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958376"><span class="hs-identifier hs-var">old_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Core.TyCo.FVs.html#noFreeVarsOfType"><span class="hs-identifier hs-var">noFreeVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680958375"><span class="hs-identifier hs-var">old_w</span></a></span><span>
</span><span id="line-1019"></span><span>    </span><span id="local-6989586621680958378"><span class="annot"><span class="annottext">subst :: TCvSubst
</span><a href="#local-6989586621680958378"><span class="hs-identifier hs-var hs-var">subst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680958386"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680958385"><span class="hs-identifier hs-var">tv_env</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680958384"><span class="hs-identifier hs-var">cv_env</span></a></span><span>
</span><span id="line-1020"></span><span>    </span><span id="local-6989586621680958376"><span class="annot"><span class="annottext">old_ty :: Type
</span><a href="#local-6989586621680958376"><span class="hs-identifier hs-var hs-var">old_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InBndr -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958383"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-1021"></span><span>    </span><span id="local-6989586621680958375"><span class="annot"><span class="annottext">old_w :: Type
</span><a href="#local-6989586621680958375"><span class="hs-identifier hs-var hs-var">old_w</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InBndr -&gt; Type
</span><a href="GHC.Types.Var.html#varMult"><span class="hs-identifier hs-var hs-var">varMult</span></a></span><span> </span><span class="annot"><span class="annottext">InBndr
</span><a href="#local-6989586621680958383"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-1022"></span></pre></body></html>